Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: source/patched-ffmpeg-mt/ffmpeg.c

Issue 3384002: ffmpeg source update for sep 09 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/patched-ffmpeg-mt/doc/protocols.texi ('k') | source/patched-ffmpeg-mt/ffplay.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * FFmpeg main 2 * FFmpeg main
3 * Copyright (c) 2000-2003 Fabrice Bellard 3 * Copyright (c) 2000-2003 Fabrice Bellard
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 int64_t sample_index; /* current sample */ 302 int64_t sample_index; /* current sample */
303 303
304 int64_t start; /* time when read started */ 304 int64_t start; /* time when read started */
305 int64_t next_pts; /* synthetic pts for cases where pkt.pts 305 int64_t next_pts; /* synthetic pts for cases where pkt.pts
306 is not defined */ 306 is not defined */
307 int64_t pts; /* current pts */ 307 int64_t pts; /* current pts */
308 int is_start; /* is 1 at the start and after a discontinuity */ 308 int is_start; /* is 1 at the start and after a discontinuity */
309 int showed_multi_packet_warning; 309 int showed_multi_packet_warning;
310 int is_past_recording_time; 310 int is_past_recording_time;
311 #if CONFIG_AVFILTER 311 #if CONFIG_AVFILTER
312 AVFilterContext *out_video_filter; 312 AVFilterContext *output_video_filter;
313 AVFilterContext *input_video_filter; 313 AVFilterContext *input_video_filter;
314 AVFrame *filter_frame; 314 AVFrame *filter_frame;
315 int has_filter_frame; 315 int has_filter_frame;
316 AVFilterBufferRef *picref; 316 AVFilterBufferRef *picref;
317 #endif 317 #endif
318 } AVInputStream; 318 } AVInputStream;
319 319
320 typedef struct AVInputFile { 320 typedef struct AVInputFile {
321 int eof_reached; /* true if eof reached */ 321 int eof_reached; /* true if eof reached */
322 int ist_index; /* index of first stream in ist_table */ 322 int ist_index; /* index of first stream in ist_table */
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return -1; 370 return -1;
371 if(!(pic = ctx->inputs[0]->cur_buf)) 371 if(!(pic = ctx->inputs[0]->cur_buf))
372 return -1; 372 return -1;
373 *picref = pic; 373 *picref = pic;
374 ctx->inputs[0]->cur_buf = NULL; 374 ctx->inputs[0]->cur_buf = NULL;
375 375
376 *pts = pic->pts; 376 *pts = pic->pts;
377 377
378 memcpy(pic2->data, pic->data, sizeof(pic->data)); 378 memcpy(pic2->data, pic->data, sizeof(pic->data));
379 memcpy(pic2->linesize, pic->linesize, sizeof(pic->linesize)); 379 memcpy(pic2->linesize, pic->linesize, sizeof(pic->linesize));
380 pic2->interlaced_frame = pic->interlaced; 380 pic2->interlaced_frame = pic->video->interlaced;
381 pic2->top_field_first = pic->top_field_first; 381 pic2->top_field_first = pic->video->top_field_first;
382 382
383 return 1; 383 return 1;
384 } 384 }
385 385
386 static AVFilter output_filter = 386 static AVFilter output_filter =
387 { 387 {
388 .name = "ffmpeg_output", 388 .name = "ffmpeg_output",
389 389
390 .priv_size = sizeof(FilterOutPriv), 390 .priv_size = sizeof(FilterOutPriv),
391 .init = output_init, 391 .init = output_init,
392 392
393 .query_formats = output_query_formats, 393 .query_formats = output_query_formats,
394 394
395 .inputs = (AVFilterPad[]) {{ .name = "default", 395 .inputs = (AVFilterPad[]) {{ .name = "default",
396 .type = AVMEDIA_TYPE_VIDEO, 396 .type = AVMEDIA_TYPE_VIDEO,
397 .end_frame = output_end_frame, 397 .end_frame = output_end_frame,
398 .min_perms = AV_PERM_READ, }, 398 .min_perms = AV_PERM_READ, },
399 { .name = NULL }}, 399 { .name = NULL }},
400 .outputs = (AVFilterPad[]) {{ .name = NULL }}, 400 .outputs = (AVFilterPad[]) {{ .name = NULL }},
401 }; 401 };
402 402
403 static int configure_filters(AVInputStream *ist, AVOutputStream *ost) 403 static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
404 { 404 {
405 AVFilterContext *last_filter, *filter; 405 AVFilterContext *last_filter, *filter;
406 /** filter graph containing all filters including input & output */ 406 /** filter graph containing all filters including input & output */
407 AVCodecContext *codec = ost->st->codec; 407 AVCodecContext *codec = ost->st->codec;
408 AVCodecContext *icodec = ist->st->codec; 408 AVCodecContext *icodec = ist->st->codec;
409 char args[255]; 409 char args[255];
410 int ret;
410 411
411 graph = av_mallocz(sizeof(AVFilterGraph)); 412 graph = av_mallocz(sizeof(AVFilterGraph));
412 413
413 if (!(ist->input_video_filter = avfilter_open(avfilter_get_by_name("buffer") , "src"))) 414 if ((ret = avfilter_open(&ist->input_video_filter, avfilter_get_by_name("buf fer"), "src")) < 0)
414 return -1; 415 return ret;
415 if (!(ist->out_video_filter = avfilter_open(&output_filter, "out"))) 416 if ((ret = avfilter_open(&ist->output_video_filter, &output_filter, "out")) < 0)
416 return -1; 417 return ret;
417 418
418 snprintf(args, 255, "%d:%d:%d", ist->st->codec->width, 419 snprintf(args, 255, "%d:%d:%d", ist->st->codec->width,
419 ist->st->codec->height, ist->st->codec->pix_fmt); 420 ist->st->codec->height, ist->st->codec->pix_fmt);
420 if (avfilter_init_filter(ist->input_video_filter, args, NULL)) 421 if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0)
421 return -1; 422 return ret;
422 if (avfilter_init_filter(ist->out_video_filter, NULL, &codec->pix_fmt)) 423 if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &codec->pix_ fmt)) < 0)
423 return -1; 424 return ret;
424 425
425 /* add input and output filters to the overall graph */ 426 /* add input and output filters to the overall graph */
426 avfilter_graph_add_filter(graph, ist->input_video_filter); 427 avfilter_graph_add_filter(graph, ist->input_video_filter);
427 avfilter_graph_add_filter(graph, ist->out_video_filter); 428 avfilter_graph_add_filter(graph, ist->output_video_filter);
428 429
429 last_filter = ist->input_video_filter; 430 last_filter = ist->input_video_filter;
430 431
431 if (ost->video_crop) { 432 if (ost->video_crop) {
432 snprintf(args, 255, "%d:%d:%d:%d", ost->leftBand, ost->topBand, 433 snprintf(args, 255, "%d:%d:%d:%d", ost->leftBand, ost->topBand,
433 codec->width, 434 codec->width,
434 codec->height); 435 codec->height);
435 filter = avfilter_open(avfilter_get_by_name("crop"), NULL); 436 if ((ret = avfilter_open(&filter, avfilter_get_by_name("crop"), NULL)) < 0)
436 if (!filter) 437 return ret;
437 return -1; 438 if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
438 if (avfilter_init_filter(filter, args, NULL)) 439 return ret;
439 return -1; 440 if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
440 if (avfilter_link(last_filter, 0, filter, 0)) 441 return ret;
441 return -1;
442 last_filter = filter; 442 last_filter = filter;
443 avfilter_graph_add_filter(graph, last_filter); 443 avfilter_graph_add_filter(graph, last_filter);
444 } 444 }
445 445
446 if((codec->width != 446 if((codec->width !=
447 icodec->width - (frame_leftBand + frame_rightBand)) || 447 icodec->width - (frame_leftBand + frame_rightBand)) ||
448 (codec->height != icodec->height - (frame_topBand + frame_bottomBand))) { 448 (codec->height != icodec->height - (frame_topBand + frame_bottomBand))) {
449 snprintf(args, 255, "%d:%d:flags=0x%X", 449 snprintf(args, 255, "%d:%d:flags=0x%X",
450 codec->width, 450 codec->width,
451 codec->height, 451 codec->height,
452 (int)av_get_int(sws_opts, "sws_flags", NULL)); 452 (int)av_get_int(sws_opts, "sws_flags", NULL));
453 filter = avfilter_open(avfilter_get_by_name("scale"), NULL); 453 if ((ret = avfilter_open(&filter, avfilter_get_by_name("scale"), NULL)) < 0)
454 if (!filter) 454 return ret;
455 return -1; 455 if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
456 if (avfilter_init_filter(filter, args, NULL)) 456 return ret;
457 return -1; 457 if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
458 if (avfilter_link(last_filter, 0, filter, 0)) 458 return ret;
459 return -1;
460 last_filter = filter; 459 last_filter = filter;
461 avfilter_graph_add_filter(graph, last_filter); 460 avfilter_graph_add_filter(graph, last_filter);
462 } 461 }
463 462
464 snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_fl ags", NULL)); 463 snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_fl ags", NULL));
465 graph->scale_sws_opts = av_strdup(args); 464 graph->scale_sws_opts = av_strdup(args);
466 465
467 if (vfilters) { 466 if (vfilters) {
468 AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut)); 467 AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
469 AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut)); 468 AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut));
470 469
471 outputs->name = av_strdup("in"); 470 outputs->name = av_strdup("in");
472 outputs->filter = last_filter; 471 outputs->filter = last_filter;
473 outputs->pad_idx = 0; 472 outputs->pad_idx = 0;
474 outputs->next = NULL; 473 outputs->next = NULL;
475 474
476 inputs->name = av_strdup("out"); 475 inputs->name = av_strdup("out");
477 inputs->filter = ist->out_video_filter; 476 inputs->filter = ist->output_video_filter;
478 inputs->pad_idx = 0; 477 inputs->pad_idx = 0;
479 inputs->next = NULL; 478 inputs->next = NULL;
480 479
481 if (avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL) < 0) 480 if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
482 return -1; 481 return ret;
483 av_freep(&vfilters); 482 av_freep(&vfilters);
484 } else { 483 } else {
485 if (avfilter_link(last_filter, 0, ist->out_video_filter, 0) < 0) 484 if ((ret = avfilter_link(last_filter, 0, ist->output_video_filter, 0)) < 0)
486 return -1; 485 return ret;
487 } 486 }
488 487
489 /* configure all the filter links */ 488 /* configure all the filter links */
490 if (avfilter_graph_check_validity(graph, NULL)) 489 if ((ret = avfilter_graph_check_validity(graph, NULL)) < 0)
491 return -1; 490 return ret;
492 if (avfilter_graph_config_formats(graph, NULL)) 491 if ((ret = avfilter_graph_config_formats(graph, NULL)) < 0)
493 return -1; 492 return ret;
494 if (avfilter_graph_config_links(graph, NULL)) 493 if ((ret = avfilter_graph_config_links(graph, NULL)) < 0)
495 return -1; 494 return ret;
496 495
497 codec->width = ist->out_video_filter->inputs[0]->w; 496 codec->width = ist->output_video_filter->inputs[0]->w;
498 codec->height = ist->out_video_filter->inputs[0]->h; 497 codec->height = ist->output_video_filter->inputs[0]->h;
499 498
500 return 0; 499 return 0;
501 } 500 }
502 #endif /* CONFIG_AVFILTER */ 501 #endif /* CONFIG_AVFILTER */
503 502
504 static void term_exit(void) 503 static void term_exit(void)
505 { 504 {
506 #if HAVE_TERMIOS_H 505 #if HAVE_TERMIOS_H
507 tcsetattr (0, TCSANOW, &oldtty); 506 tcsetattr (0, TCSANOW, &oldtty);
508 #endif 507 #endif
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 1660
1662 /* frame rate emulation */ 1661 /* frame rate emulation */
1663 if (rate_emu) { 1662 if (rate_emu) {
1664 int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE); 1663 int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE);
1665 int64_t now = av_gettime() - ist->start; 1664 int64_t now = av_gettime() - ist->start;
1666 if (pts > now) 1665 if (pts > now)
1667 usleep(pts - now); 1666 usleep(pts - now);
1668 } 1667 }
1669 #if CONFIG_AVFILTER 1668 #if CONFIG_AVFILTER
1670 frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO || 1669 frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
1671 !ist->out_video_filter || avfilter_poll_frame(ist->out_video_filter- >inputs[0]); 1670 !ist->output_video_filter || avfilter_poll_frame(ist->output_video_f ilter->inputs[0]);
1672 #endif 1671 #endif
1673 /* if output time reached then transcode raw format, 1672 /* if output time reached then transcode raw format,
1674 encode packets and output them */ 1673 encode packets and output them */
1675 if (start_time == 0 || ist->pts >= start_time) 1674 if (start_time == 0 || ist->pts >= start_time)
1676 #if CONFIG_AVFILTER 1675 #if CONFIG_AVFILTER
1677 while (frame_available) { 1676 while (frame_available) {
1678 if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ist->out_vid eo_filter) 1677 if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ist->output_ video_filter)
1679 get_filtered_video_pic(ist->out_video_filter, &ist->picref, &pic ture, &ist->pts); 1678 get_filtered_video_pic(ist->output_video_filter, &ist->picref, & picture, &ist->pts);
1680 #endif 1679 #endif
1681 for(i=0;i<nb_ostreams;i++) { 1680 for(i=0;i<nb_ostreams;i++) {
1682 int frame_size; 1681 int frame_size;
1683 1682
1684 ost = ost_table[i]; 1683 ost = ost_table[i];
1685 if (ost->source_index == ist_index) { 1684 if (ost->source_index == ist_index) {
1686 os = output_files[ost->file_index]; 1685 os = output_files[ost->file_index];
1687 1686
1688 /* set the input output pts pairs */ 1687 /* set the input output pts pairs */
1689 //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset [ist->file_index] - start_time)/ AV_TIME_BASE; 1688 //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset [ist->file_index] - start_time)/ AV_TIME_BASE;
1690 1689
1691 if (ost->encoding_needed) { 1690 if (ost->encoding_needed) {
1692 assert(ist->decoding_needed); 1691 assert(ist->decoding_needed);
1693 switch(ost->st->codec->codec_type) { 1692 switch(ost->st->codec->codec_type) {
1694 case AVMEDIA_TYPE_AUDIO: 1693 case AVMEDIA_TYPE_AUDIO:
1695 do_audio_out(os, ost, ist, decoded_data_buf, decoded _data_size); 1694 do_audio_out(os, ost, ist, decoded_data_buf, decoded _data_size);
1696 break; 1695 break;
1697 case AVMEDIA_TYPE_VIDEO: 1696 case AVMEDIA_TYPE_VIDEO:
1698 #if CONFIG_AVFILTER 1697 #if CONFIG_AVFILTER
1699 ost->st->codec->sample_aspect_ratio = ist->picref->p ixel_aspect; 1698 if (ist->picref->video)
1699 ost->st->codec->sample_aspect_ratio = ist->picre f->video->pixel_aspect;
1700 #endif 1700 #endif
1701 do_video_out(os, ost, ist, &picture, &frame_size); 1701 do_video_out(os, ost, ist, &picture, &frame_size);
1702 if (vstats_filename && frame_size) 1702 if (vstats_filename && frame_size)
1703 do_video_stats(os, ost, frame_size); 1703 do_video_stats(os, ost, frame_size);
1704 break; 1704 break;
1705 case AVMEDIA_TYPE_SUBTITLE: 1705 case AVMEDIA_TYPE_SUBTITLE:
1706 do_subtitle_out(os, ost, ist, &subtitle, 1706 do_subtitle_out(os, ost, ist, &subtitle,
1707 pkt->pts); 1707 pkt->pts);
1708 break; 1708 break;
1709 default: 1709 default:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 write_frame(os, &opkt, ost->st->codec, bitstream_filters [ost->file_index][opkt.stream_index]); 1763 write_frame(os, &opkt, ost->st->codec, bitstream_filters [ost->file_index][opkt.stream_index]);
1764 ost->st->codec->frame_number++; 1764 ost->st->codec->frame_number++;
1765 ost->frame_number++; 1765 ost->frame_number++;
1766 av_free_packet(&opkt); 1766 av_free_packet(&opkt);
1767 } 1767 }
1768 } 1768 }
1769 } 1769 }
1770 1770
1771 #if CONFIG_AVFILTER 1771 #if CONFIG_AVFILTER
1772 frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && 1772 frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
1773 ist->out_video_filter && avfilter_poll_frame(ist-> out_video_filter->inputs[0]); 1773 ist->output_video_filter && avfilter_poll_frame(is t->output_video_filter->inputs[0]);
1774 if(ist->picref) 1774 if(ist->picref)
1775 avfilter_unref_buffer(ist->picref); 1775 avfilter_unref_buffer(ist->picref);
1776 } 1776 }
1777 #endif 1777 #endif
1778 av_free(buffer_to_free); 1778 av_free(buffer_to_free);
1779 /* XXX: allocate the subtitles in the codec ? */ 1779 /* XXX: allocate the subtitles in the codec ? */
1780 if (subtitle_to_free) { 1780 if (subtitle_to_free) {
1781 if (subtitle_to_free->rects != NULL) { 1781 if (subtitle_to_free->rects != NULL) {
1782 for (i = 0; i < subtitle_to_free->num_rects; i++) { 1782 for (i = 0; i < subtitle_to_free->num_rects; i++) {
1783 av_freep(&subtitle_to_free->rects[i]->pict.data[0]); 1783 av_freep(&subtitle_to_free->rects[i]->pict.data[0]);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 int i= ost->file_index; 2060 int i= ost->file_index;
2061 dump_format(output_files[i], i, output_files[i]->filename, 1 ); 2061 dump_format(output_files[i], i, output_files[i]->filename, 1 );
2062 fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> # %d.%d\n", 2062 fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> # %d.%d\n",
2063 stream_maps[n].file_index, stream_maps[n].stream_index, 2063 stream_maps[n].file_index, stream_maps[n].stream_index,
2064 ost->file_index, ost->index); 2064 ost->file_index, ost->index);
2065 ffmpeg_exit(1); 2065 ffmpeg_exit(1);
2066 } 2066 }
2067 2067
2068 } else { 2068 } else {
2069 int best_nb_frames=-1; 2069 int best_nb_frames=-1;
2070 /* get corresponding input stream index : we select the firs t one with the right type */ 2070 /* get corresponding input stream index : we select the first on e with the right type */
2071 found = 0; 2071 found = 0;
2072 for(j=0;j<nb_istreams;j++) { 2072 for(j=0;j<nb_istreams;j++) {
2073 int skip=0; 2073 int skip=0;
2074 ist = ist_table[j]; 2074 ist = ist_table[j];
2075 if(opt_programid){ 2075 if(opt_programid){
2076 int pi,si; 2076 int pi,si;
2077 AVFormatContext *f= input_files[ ist->file_index ]; 2077 AVFormatContext *f= input_files[ ist->file_index ];
2078 skip=1; 2078 skip=1;
2079 for(pi=0; pi<f->nb_programs; pi++){ 2079 for(pi=0; pi<f->nb_programs; pi++){
2080 AVProgram *p= f->programs[pi]; 2080 AVProgram *p= f->programs[pi];
2081 if(p->id == opt_programid) 2081 if(p->id == opt_programid)
2082 for(si=0; si<p->nb_stream_indexes; si++){ 2082 for(si=0; si<p->nb_stream_indexes; si++){
2083 if(f->streams[ p->stream_index[si] ] == ist->st) 2083 if(f->streams[ p->stream_index[si] ] == ist- >st)
2084 skip=0; 2084 skip=0;
2085 } 2085 }
2086 }
2087 }
2088 if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip &&
2089 ist->st->codec->codec_type == ost->st->codec->codec_ type) {
2090 if(best_nb_frames < ist->st->codec_info_nb_frames){
2091 best_nb_frames= ist->st->codec_info_nb_frames;
2092 ost->source_index = j;
2093 found = 1;
2094 }
2095 } 2086 }
2096 } 2087 }
2088 if (ist->discard && ist->st->discard != AVDISCARD_ALL && !sk ip &&
2089 ist->st->codec->codec_type == ost->st->codec->codec_type ) {
2090 if(best_nb_frames < ist->st->codec_info_nb_frames){
2091 best_nb_frames= ist->st->codec_info_nb_frames;
2092 ost->source_index = j;
2093 found = 1;
2094 }
2095 }
2096 }
2097 2097
2098 if (!found) { 2098 if (!found) {
2099 if(! opt_programid) { 2099 if(! opt_programid) {
2100 /* try again and reuse existing stream */ 2100 /* try again and reuse existing stream */
2101 for(j=0;j<nb_istreams;j++) { 2101 for(j=0;j<nb_istreams;j++) {
2102 ist = ist_table[j]; 2102 ist = ist_table[j];
2103 if ( ist->st->codec->codec_type == ost->st->codec- >codec_type 2103 if ( ist->st->codec->codec_type == ost->st->codec- >codec_type
2104 && ist->st->discard != AVDISCARD_ALL) { 2104 && ist->st->discard != AVDISCARD_ALL) {
2105 ost->source_index = j; 2105 ost->source_index = j;
2106 found = 1; 2106 found = 1;
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2525 if(no_packet_count){ 2525 if(no_packet_count){
2526 no_packet_count=0; 2526 no_packet_count=0;
2527 memset(no_packet, 0, sizeof(no_packet)); 2527 memset(no_packet, 0, sizeof(no_packet));
2528 usleep(10000); 2528 usleep(10000);
2529 continue; 2529 continue;
2530 } 2530 }
2531 break; 2531 break;
2532 } 2532 }
2533 2533
2534 /* finish if limit size exhausted */ 2534 /* finish if limit size exhausted */
2535 if (limit_filesize != 0 && limit_filesize < url_ftell(output_files[0]->p b)) 2535 if (limit_filesize != 0 && limit_filesize <= url_ftell(output_files[0]-> pb))
2536 break; 2536 break;
2537 2537
2538 /* read a frame from it and output it in the fifo */ 2538 /* read a frame from it and output it in the fifo */
2539 is = input_files[file_index]; 2539 is = input_files[file_index];
2540 ret= av_read_frame(is, &pkt); 2540 ret= av_read_frame(is, &pkt);
2541 if(ret == AVERROR(EAGAIN)){ 2541 if(ret == AVERROR(EAGAIN)){
2542 no_packet[file_index]=1; 2542 no_packet[file_index]=1;
2543 no_packet_count++; 2543 no_packet_count++;
2544 continue; 2544 continue;
2545 } 2545 }
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
3229 case AVMEDIA_TYPE_AUDIO: 3229 case AVMEDIA_TYPE_AUDIO:
3230 set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_ AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM); 3230 set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_ AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM);
3231 //fprintf(stderr, "\nInput Audio channels: %d", dec->channels); 3231 //fprintf(stderr, "\nInput Audio channels: %d", dec->channels);
3232 channel_layout = dec->channel_layout; 3232 channel_layout = dec->channel_layout;
3233 audio_channels = dec->channels; 3233 audio_channels = dec->channels;
3234 audio_sample_rate = dec->sample_rate; 3234 audio_sample_rate = dec->sample_rate;
3235 audio_sample_fmt = dec->sample_fmt; 3235 audio_sample_fmt = dec->sample_fmt;
3236 input_codecs[nb_icodecs++] = avcodec_find_decoder_by_name(audio_code c_name); 3236 input_codecs[nb_icodecs++] = avcodec_find_decoder_by_name(audio_code c_name);
3237 if(audio_disable) 3237 if(audio_disable)
3238 st->discard= AVDISCARD_ALL; 3238 st->discard= AVDISCARD_ALL;
3239 /* Note that av_find_stream_info can add more streams, and we
3240 * currently have no chance of setting up lowres decoding
3241 * early enough for them. */
3242 if (dec->lowres)
3243 audio_sample_rate >>= dec->lowres;
3239 break; 3244 break;
3240 case AVMEDIA_TYPE_VIDEO: 3245 case AVMEDIA_TYPE_VIDEO:
3241 set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_ VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM); 3246 set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_ VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM);
3242 frame_height = dec->height; 3247 frame_height = dec->height;
3243 frame_width = dec->width; 3248 frame_width = dec->width;
3244 if(ic->streams[i]->sample_aspect_ratio.num) 3249 if(ic->streams[i]->sample_aspect_ratio.num)
3245 frame_aspect_ratio=av_q2d(ic->streams[i]->sample_aspect_ratio); 3250 frame_aspect_ratio=av_q2d(ic->streams[i]->sample_aspect_ratio);
3246 else 3251 else
3247 frame_aspect_ratio=av_q2d(dec->sample_aspect_ratio); 3252 frame_aspect_ratio=av_q2d(dec->sample_aspect_ratio);
3248 frame_aspect_ratio *= (float) dec->width / dec->height; 3253 frame_aspect_ratio *= (float) dec->width / dec->height;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 if (subtitle_language) { 3594 if (subtitle_language) {
3590 av_metadata_set2(&st->metadata, "language", subtitle_language, 0); 3595 av_metadata_set2(&st->metadata, "language", subtitle_language, 0);
3591 av_freep(&subtitle_language); 3596 av_freep(&subtitle_language);
3592 } 3597 }
3593 3598
3594 subtitle_disable = 0; 3599 subtitle_disable = 0;
3595 av_freep(&subtitle_codec_name); 3600 av_freep(&subtitle_codec_name);
3596 subtitle_stream_copy = 0; 3601 subtitle_stream_copy = 0;
3597 } 3602 }
3598 3603
3599 static void opt_new_audio_stream(void) 3604 static void opt_new_stream(const char *opt, const char *arg)
3600 { 3605 {
3601 AVFormatContext *oc; 3606 AVFormatContext *oc;
3602 if (nb_output_files <= 0) { 3607 if (nb_output_files <= 0) {
3603 fprintf(stderr, "At least one output file must be specified\n"); 3608 fprintf(stderr, "At least one output file must be specified\n");
3604 ffmpeg_exit(1); 3609 ffmpeg_exit(1);
3605 } 3610 }
3606 oc = output_files[nb_output_files - 1]; 3611 oc = output_files[nb_output_files - 1];
3607 new_audio_stream(oc);
3608 }
3609 3612
3610 static void opt_new_video_stream(void) 3613 if (!strcmp(opt, "newvideo" )) new_video_stream (oc);
3611 { 3614 else if (!strcmp(opt, "newaudio" )) new_audio_stream (oc);
3612 AVFormatContext *oc; 3615 else if (!strcmp(opt, "newsubtitle")) new_subtitle_stream(oc);
3613 if (nb_output_files <= 0) { 3616 else assert(0);
3614 fprintf(stderr, "At least one output file must be specified\n");
3615 ffmpeg_exit(1);
3616 }
3617 oc = output_files[nb_output_files - 1];
3618 new_video_stream(oc);
3619 }
3620
3621 static void opt_new_subtitle_stream(void)
3622 {
3623 AVFormatContext *oc;
3624 if (nb_output_files <= 0) {
3625 fprintf(stderr, "At least one output file must be specified\n");
3626 ffmpeg_exit(1);
3627 }
3628 oc = output_files[nb_output_files - 1];
3629 new_subtitle_stream(oc);
3630 } 3617 }
3631 3618
3632 /* arg format is "output-stream-index:streamid-value". */ 3619 /* arg format is "output-stream-index:streamid-value". */
3633 static void opt_streamid(const char *opt, const char *arg) 3620 static void opt_streamid(const char *opt, const char *arg)
3634 { 3621 {
3635 int idx; 3622 int idx;
3636 char *p; 3623 char *p;
3637 char idx_str[16]; 3624 char idx_str[16];
3638 3625
3639 strncpy(idx_str, arg, sizeof(idx_str)); 3626 strncpy(idx_str, arg, sizeof(idx_str));
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
4246 { "vstats", OPT_EXPERT | OPT_VIDEO, {(void*)&opt_vstats}, "dump video coding statistics to file" }, 4233 { "vstats", OPT_EXPERT | OPT_VIDEO, {(void*)&opt_vstats}, "dump video coding statistics to file" },
4247 { "vstats_file", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_vstats_file}, "dump video coding statistics to file", "file" }, 4234 { "vstats_file", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_vstats_file}, "dump video coding statistics to file", "file" },
4248 #if CONFIG_AVFILTER 4235 #if CONFIG_AVFILTER
4249 { "vf", OPT_STRING | HAS_ARG, {(void*)&vfilters}, "video filters", "filter l ist" }, 4236 { "vf", OPT_STRING | HAS_ARG, {(void*)&vfilters}, "video filters", "filter l ist" },
4250 #endif 4237 #endif
4251 { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_intra_matrix }, "specify intra matrix coeffs", "matrix" }, 4238 { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_intra_matrix }, "specify intra matrix coeffs", "matrix" },
4252 { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_inter_matrix }, "specify inter matrix coeffs", "matrix" }, 4239 { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_inter_matrix }, "specify inter matrix coeffs", "matrix" },
4253 { "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_top_field_first}, "to p=1/bottom=0/auto=-1 field first", "" }, 4240 { "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_top_field_first}, "to p=1/bottom=0/auto=-1 field first", "" },
4254 { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_dc_precis ion}, "intra_dc_precision", "precision" }, 4241 { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_dc_precis ion}, "intra_dc_precision", "precision" },
4255 { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_tag}, "force v ideo tag/fourcc", "fourcc/tag" }, 4242 { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_tag}, "force v ideo tag/fourcc", "fourcc/tag" },
4256 { "newvideo", OPT_VIDEO, {(void*)opt_new_video_stream}, "add a new video str eam to the current output stream" }, 4243 { "newvideo", OPT_VIDEO | OPT_FUNC2, {(void*)opt_new_stream}, "add a new vid eo stream to the current output stream" },
4257 { "vlang", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void *)&video_language}, "set the ISO 639 language code (3 letters) of the current video stream" , "code" }, 4244 { "vlang", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void *)&video_language}, "set the ISO 639 language code (3 letters) of the current video stream" , "code" },
4258 { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show Q P histogram" }, 4245 { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show Q P histogram" },
4259 { "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&force_fps}, "forc e the selected framerate, disable the best supported framerate selection" }, 4246 { "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&force_fps}, "forc e the selected framerate, disable the best supported framerate selection" },
4260 { "streamid", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" }, 4247 { "streamid", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" },
4261 4248
4262 /* audio options */ 4249 /* audio options */
4263 { "ab", OPT_FUNC2 | HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" }, 4250 { "ab", OPT_FUNC2 | HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
4264 { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[AVMEDIA_TYPE _AUDIO]}, "set the number of audio frames to record", "number" }, 4251 { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[AVMEDIA_TYPE _AUDIO]}, "set the number of audio frames to record", "number" },
4265 { "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set audio quality (codec-specific)", "quality", }, 4252 { "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set audio quality (codec-specific)", "quality", },
4266 { "ar", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" }, 4253 { "ar", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" },
4267 { "ac", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_channels}, "set n umber of audio channels", "channels" }, 4254 { "ac", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_channels}, "set n umber of audio channels", "channels" },
4268 { "an", OPT_BOOL | OPT_AUDIO, {(void*)&audio_disable}, "disable audio" }, 4255 { "an", OPT_BOOL | OPT_AUDIO, {(void*)&audio_disable}, "disable audio" },
4269 { "acodec", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_codec}, "force audio code c ('copy' to copy stream)", "codec" }, 4256 { "acodec", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_codec}, "force audio code c ('copy' to copy stream)", "codec" },
4270 { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_audio_tag}, "force a udio tag/fourcc", "fourcc/tag" }, 4257 { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_audio_tag}, "force a udio tag/fourcc", "fourcc/tag" },
4271 { "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change audi o volume (256=normal)" , "volume" }, // 4258 { "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change audi o volume (256=normal)" , "volume" }, //
4272 { "newaudio", OPT_AUDIO, {(void*)opt_new_audio_stream}, "add a new audio str eam to the current output stream" }, 4259 { "newaudio", OPT_AUDIO | OPT_FUNC2, {(void*)opt_new_stream}, "add a new aud io stream to the current output stream" },
4273 { "alang", HAS_ARG | OPT_STRING | OPT_AUDIO, {(void *)&audio_language}, "set the ISO 639 language code (3 letters) of the current audio stream" , "code" }, 4260 { "alang", HAS_ARG | OPT_STRING | OPT_AUDIO, {(void *)&audio_language}, "set the ISO 639 language code (3 letters) of the current audio stream" , "code" },
4274 { "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_audio_sample_f mt}, "set sample format, 'list' as argument shows all the sample formats support ed", "format" }, 4261 { "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_audio_sample_f mt}, "set sample format, 'list' as argument shows all the sample formats support ed", "format" },
4275 4262
4276 /* subtitle options */ 4263 /* subtitle options */
4277 { "sn", OPT_BOOL | OPT_SUBTITLE, {(void*)&subtitle_disable}, "disable subtit le" }, 4264 { "sn", OPT_BOOL | OPT_SUBTITLE, {(void*)&subtitle_disable}, "disable subtit le" },
4278 { "scodec", HAS_ARG | OPT_SUBTITLE, {(void*)opt_subtitle_codec}, "force subt itle codec ('copy' to copy stream)", "codec" }, 4265 { "scodec", HAS_ARG | OPT_SUBTITLE, {(void*)opt_subtitle_codec}, "force subt itle codec ('copy' to copy stream)", "codec" },
4279 { "newsubtitle", OPT_SUBTITLE, {(void*)opt_new_subtitle_stream}, "add a new subtitle stream to the current output stream" }, 4266 { "newsubtitle", OPT_SUBTITLE | OPT_FUNC2, {(void*)opt_new_stream}, "add a n ew subtitle stream to the current output stream" },
4280 { "slang", HAS_ARG | OPT_STRING | OPT_SUBTITLE, {(void *)&subtitle_language} , "set the ISO 639 language code (3 letters) of the current subtitle stream" , " code" }, 4267 { "slang", HAS_ARG | OPT_STRING | OPT_SUBTITLE, {(void *)&subtitle_language} , "set the ISO 639 language code (3 letters) of the current subtitle stream" , " code" },
4281 { "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE, {(void*)opt_subtitle_tag}, "f orce subtitle tag/fourcc", "fourcc/tag" }, 4268 { "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE, {(void*)opt_subtitle_tag}, "f orce subtitle tag/fourcc", "fourcc/tag" },
4282 4269
4283 /* grab options */ 4270 /* grab options */
4284 { "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_chann el}, "set video grab channel (DV1394 only)", "channel" }, 4271 { "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_chann el}, "set video grab channel (DV1394 only)", "channel" },
4285 { "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_st andard}, "set television standard (NTSC, PAL (SECAM))", "standard" }, 4272 { "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_st andard}, "set television standard (NTSC, PAL (SECAM))", "standard" },
4286 { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {(void*)&input_sync}, "sync rea d on input", "" }, 4273 { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {(void*)&input_sync}, "sync rea d on input", "" },
4287 4274
4288 /* muxer options */ 4275 /* muxer options */
4289 { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_max_delay}, "se t the maximum demux-decode delay", "seconds" }, 4276 { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_max_delay}, "se t the maximum demux-decode delay", "seconds" },
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
4354 stream_maps, nb_stream_maps) < 0) 4341 stream_maps, nb_stream_maps) < 0)
4355 ffmpeg_exit(1); 4342 ffmpeg_exit(1);
4356 ti = getutime() - ti; 4343 ti = getutime() - ti;
4357 if (do_benchmark) { 4344 if (do_benchmark) {
4358 int maxrss = getmaxrss() / 1024; 4345 int maxrss = getmaxrss() / 1024;
4359 printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss); 4346 printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss);
4360 } 4347 }
4361 4348
4362 return ffmpeg_exit(0); 4349 return ffmpeg_exit(0);
4363 } 4350 }
OLDNEW
« no previous file with comments | « source/patched-ffmpeg-mt/doc/protocols.texi ('k') | source/patched-ffmpeg-mt/ffplay.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698