Patch by Nicolas George -bsf nicolas*george|normalesup+org. Originally committed as revision 25501 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -247,8 +247,6 @@ static short *samples; · 246 unmodified lines | ||
| 247 | 247 | static AVBitStreamFilterContext *video_bitstream_filters=NULL; |
| 248 | 248 | static AVBitStreamFilterContext *audio_bitstream_filters=NULL; |
| 249 | 249 | static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL; |
| 250 | −static AVBitStreamFilterContext **bitstream_filters[MAX_FILES] = {NULL}; | |
| 251 | −static int nb_bitstream_filters[MAX_FILES] = {0}; | |
| 252 | 250 | |
| 253 | 251 | #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" |
| 254 | 252 | |
| @@ -266,6 +264,7 @@ typedef struct AVOutputStream { · 11 unmodified lines | ||
| 266 | 264 | //double sync_ipts; /* dts from the AVPacket of the demuxer in second units */ |
| 267 | 265 | struct AVInputStream *sync_ist; /* input stream to sync against */ |
| 268 | 266 | int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ //FIXME look at frame_number |
| 267 | + AVBitStreamFilterContext *bitstream_filters; | |
| 269 | 268 | /* video only */ |
| 270 | 269 | int video_resample; |
| 271 | 270 | AVFrame pict_tmp; /* temporary image for resampling */ |
| @@ -572,7 +571,6 @@ static int ffmpeg_exit(int ret) · 300 unmodified lines | ||
| 572 | 571 | } |
| 573 | 572 | av_metadata_free(&s->metadata); |
| 574 | 573 | av_free(s); |
| 575 | − av_free(bitstream_filters[i]); | |
| 576 | 574 | av_free(output_streams_for_file[i]); |
| 577 | 575 | } |
| 578 | 576 | for(i=0;i<nb_input_files;i++) { |
| @@ -967,7 +965,7 @@ need_realloc: · 388 unmodified lines | ||
| 967 | 965 | if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) |
| 968 | 966 | pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); |
| 969 | 967 | pkt.flags |= AV_PKT_FLAG_KEY; |
| 970 | − write_frame(s, &pkt, enc, bitstream_filters[ost->file_index][pkt.stream_index]); | |
| 968 | + write_frame(s, &pkt, enc, ost->bitstream_filters); | |
| 971 | 969 | |
| 972 | 970 | ost->sync_opts += enc->frame_size; |
| 973 | 971 | } |
| @@ -1002,7 +1000,7 @@ need_realloc: · 28 unmodified lines | ||
| 1002 | 1000 | if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) |
| 1003 | 1001 | pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); |
| 1004 | 1002 | pkt.flags |= AV_PKT_FLAG_KEY; |
| 1005 | − write_frame(s, &pkt, enc, bitstream_filters[ost->file_index][pkt.stream_index]); | |
| 1003 | + write_frame(s, &pkt, enc, ost->bitstream_filters); | |
| 1006 | 1004 | } |
| 1007 | 1005 | } |
| 1008 | 1006 | |
| @@ -1107,7 +1105,7 @@ static void do_subtitle_out(AVFormatContext *s, · 98 unmodified lines | ||
| 1107 | 1105 | else |
| 1108 | 1106 | pkt.pts += 90 * sub->end_display_time; |
| 1109 | 1107 | } |
| 1110 | − write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]); | |
| 1108 | + write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters); | |
| 1111 | 1109 | } |
| 1112 | 1110 | } |
| 1113 | 1111 | |
| @@ -1267,7 +1265,7 @@ static void do_video_out(AVFormatContext *s, · 153 unmodified lines | ||
| 1267 | 1265 | pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base); |
| 1268 | 1266 | pkt.flags |= AV_PKT_FLAG_KEY; |
| 1269 | 1267 | |
| 1270 | − write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]); | |
| 1268 | + write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters); | |
| 1271 | 1269 | enc->coded_frame = old_frame; |
| 1272 | 1270 | } else { |
| 1273 | 1271 | AVFrame big_picture; |
| @@ -1311,7 +1309,7 @@ static void do_video_out(AVFormatContext *s, · 37 unmodified lines | ||
| 1311 | 1309 | |
| 1312 | 1310 | if(enc->coded_frame->key_frame) |
| 1313 | 1311 | pkt.flags |= AV_PKT_FLAG_KEY; |
| 1314 | − write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]); | |
| 1312 | + write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters); | |
| 1315 | 1313 | *frame_size = ret; |
| 1316 | 1314 | video_size += ret; |
| 1317 | 1315 | //fprintf(stderr,"\nFrame: %3d size: %5d type: %d", |
| @@ -1766,7 +1764,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 448 unmodified lines | ||
| 1766 | 1764 | opkt.size = data_size; |
| 1767 | 1765 | } |
| 1768 | 1766 | |
| 1769 | − write_frame(os, &opkt, ost->st->codec, bitstream_filters[ost->file_index][opkt.stream_index]); | |
| 1767 | + write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters); | |
| 1770 | 1768 | ost->st->codec->frame_number++; |
| 1771 | 1769 | ost->frame_number++; |
| 1772 | 1770 | av_free_packet(&opkt); |
| @@ -1875,7 +1873,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 102 unmodified lines | ||
| 1875 | 1873 | pkt.size= ret; |
| 1876 | 1874 | if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) |
| 1877 | 1875 | pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); |
| 1878 | − write_frame(os, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]); | |
| 1876 | + write_frame(os, &pkt, ost->st->codec, ost->bitstream_filters); | |
| 1879 | 1877 | } |
| 1880 | 1878 | } |
| 1881 | 1879 | } |
| @@ -3401,11 +3399,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) · 1519 unmodified lines | ||
| 3401 | 3399 | } |
| 3402 | 3400 | |
| 3403 | 3401 | avcodec_get_context_defaults3(st->codec, codec); |
| 3404 | − bitstream_filters[file_idx] = | |
| 3405 | − grow_array(bitstream_filters[file_idx], | |
| 3406 | − sizeof(*bitstream_filters[file_idx]), | |
| 3407 | − &nb_bitstream_filters[file_idx], oc->nb_streams); | |
| 3408 | − bitstream_filters[file_idx][oc->nb_streams - 1]= video_bitstream_filters; | |
| 3402 | + ost->bitstream_filters = video_bitstream_filters; | |
| 3409 | 3403 | video_bitstream_filters= NULL; |
| 3410 | 3404 | |
| 3411 | 3405 | avcodec_thread_init(st->codec, thread_count); |
| @@ -3548,11 +3542,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) · 136 unmodified lines | ||
| 3548 | 3542 | |
| 3549 | 3543 | avcodec_get_context_defaults3(st->codec, codec); |
| 3550 | 3544 | |
| 3551 | − bitstream_filters[file_idx] = | |
| 3552 | − grow_array(bitstream_filters[file_idx], | |
| 3553 | − sizeof(*bitstream_filters[file_idx]), | |
| 3554 | − &nb_bitstream_filters[file_idx], oc->nb_streams); | |
| 3555 | − bitstream_filters[file_idx][oc->nb_streams - 1]= audio_bitstream_filters; | |
| 3545 | + ost->bitstream_filters = audio_bitstream_filters; | |
| 3556 | 3546 | audio_bitstream_filters= NULL; |
| 3557 | 3547 | |
| 3558 | 3548 | avcodec_thread_init(st->codec, thread_count); |
| @@ -3622,11 +3612,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) · 63 unmodified lines | ||
| 3622 | 3612 | } |
| 3623 | 3613 | avcodec_get_context_defaults3(st->codec, codec); |
| 3624 | 3614 | |
| 3625 | − bitstream_filters[file_idx] = | |
| 3626 | − grow_array(bitstream_filters[file_idx], | |
| 3627 | − sizeof(*bitstream_filters[file_idx]), | |
| 3628 | − &nb_bitstream_filters[file_idx], oc->nb_streams); | |
| 3629 | − bitstream_filters[file_idx][oc->nb_streams - 1]= subtitle_bitstream_filters; | |
| 3615 | + ost->bitstream_filters = subtitle_bitstream_filters; | |
| 3630 | 3616 | subtitle_bitstream_filters= NULL; |
| 3631 | 3617 | |
| 3632 | 3618 | subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; |