History

Place the bitstream_filters variable in the AVOutputStream, thus greatly simplifying its handling and reducing code duplication.

Patch by Nicolas George -bsf nicolas*george|normalesup+org. Originally committed as revision 25501 to svn://svn.ffmpeg.org/ffmpeg/trunk

Nicolas George committed 16 years ago

Commit 0b6d3581 parent 9fdf4b51 file · +11 −25Browse files

Unified · Split

ffmpeg.c+11−25
@@ -247,8 +247,6 @@ static short *samples; · 246 unmodified lines
247static AVBitStreamFilterContext *video_bitstream_filters=NULL;247static AVBitStreamFilterContext *video_bitstream_filters=NULL;
248static AVBitStreamFilterContext *audio_bitstream_filters=NULL;248static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
249static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL;249static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL;
250static AVBitStreamFilterContext **bitstream_filters[MAX_FILES] = {NULL};
251static int nb_bitstream_filters[MAX_FILES] = {0};
252 250
253#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"251#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
254 252
@@ -266,6 +264,7 @@ typedef struct AVOutputStream { · 11 unmodified lines
266 //double sync_ipts; /* dts from the AVPacket of the demuxer in second units */264 //double sync_ipts; /* dts from the AVPacket of the demuxer in second units */
267 struct AVInputStream *sync_ist; /* input stream to sync against */265 struct AVInputStream *sync_ist; /* input stream to sync against */
268 int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ //FIXME look at frame_number266 int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ //FIXME look at frame_number
267 AVBitStreamFilterContext *bitstream_filters;
269 /* video only */268 /* video only */
270 int video_resample;269 int video_resample;
271 AVFrame pict_tmp; /* temporary image for resampling */270 AVFrame pict_tmp; /* temporary image for resampling */
@@ -572,7 +571,6 @@ static int ffmpeg_exit(int ret) · 300 unmodified lines
572 }571 }
573 av_metadata_free(&s->metadata);572 av_metadata_free(&s->metadata);
574 av_free(s);573 av_free(s);
575 av_free(bitstream_filters[i]);
576 av_free(output_streams_for_file[i]);574 av_free(output_streams_for_file[i]);
577 }575 }
578 for(i=0;i<nb_input_files;i++) {576 for(i=0;i<nb_input_files;i++) {
@@ -967,7 +965,7 @@ need_realloc: · 388 unmodified lines
967 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)965 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
968 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);966 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
969 pkt.flags |= AV_PKT_FLAG_KEY;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 ost->sync_opts += enc->frame_size;970 ost->sync_opts += enc->frame_size;
973 }971 }
@@ -1002,7 +1000,7 @@ need_realloc: · 28 unmodified lines
1002 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)1000 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
1003 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);1001 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
1004 pkt.flags |= AV_PKT_FLAG_KEY;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 else1105 else
1108 pkt.pts += 90 * sub->end_display_time;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 pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);1265 pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
1268 pkt.flags |= AV_PKT_FLAG_KEY;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 enc->coded_frame = old_frame;1269 enc->coded_frame = old_frame;
1272 } else {1270 } else {
1273 AVFrame big_picture;1271 AVFrame big_picture;
@@ -1311,7 +1309,7 @@ static void do_video_out(AVFormatContext *s, · 37 unmodified lines
1311 1309
1312 if(enc->coded_frame->key_frame)1310 if(enc->coded_frame->key_frame)
1313 pkt.flags |= AV_PKT_FLAG_KEY;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 *frame_size = ret;1313 *frame_size = ret;
1316 video_size += ret;1314 video_size += ret;
1317 //fprintf(stderr,"\nFrame: %3d size: %5d type: %d",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 opkt.size = data_size;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 ost->st->codec->frame_number++;1768 ost->st->codec->frame_number++;
1771 ost->frame_number++;1769 ost->frame_number++;
1772 av_free_packet(&opkt);1770 av_free_packet(&opkt);
@@ -1875,7 +1873,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 102 unmodified lines
1875 pkt.size= ret;1873 pkt.size= ret;
1876 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)1874 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
1877 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);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 avcodec_get_context_defaults3(st->codec, codec);3401 avcodec_get_context_defaults3(st->codec, codec);
3404 bitstream_filters[file_idx] =3402 ost->bitstream_filters = video_bitstream_filters;
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;
3409 video_bitstream_filters= NULL;3403 video_bitstream_filters= NULL;
3410 3404
3411 avcodec_thread_init(st->codec, thread_count);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 avcodec_get_context_defaults3(st->codec, codec);3543 avcodec_get_context_defaults3(st->codec, codec);
3550 3544
3551 bitstream_filters[file_idx] =3545 ost->bitstream_filters = audio_bitstream_filters;
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;
3556 audio_bitstream_filters= NULL;3546 audio_bitstream_filters= NULL;
3557 3547
3558 avcodec_thread_init(st->codec, thread_count);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 avcodec_get_context_defaults3(st->codec, codec);3613 avcodec_get_context_defaults3(st->codec, codec);
3624 3614
3625 bitstream_filters[file_idx] =3615 ost->bitstream_filters = subtitle_bitstream_filters;
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;
3630 subtitle_bitstream_filters= NULL;3616 subtitle_bitstream_filters= NULL;
3631 3617
3632 subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;3618 subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t