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
247247 static AVBitStreamFilterContext *video_bitstream_filters=NULL;
248248 static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
249249 static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL;
250−static AVBitStreamFilterContext **bitstream_filters[MAX_FILES] = {NULL};
251−static int nb_bitstream_filters[MAX_FILES] = {0};
252250
253251 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
254252
@@ -266,6 +264,7 @@ typedef struct AVOutputStream { · 11 unmodified lines
266264 //double sync_ipts; /* dts from the AVPacket of the demuxer in second units */
267265 struct AVInputStream *sync_ist; /* input stream to sync against */
268266 int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ //FIXME look at frame_number
267+ AVBitStreamFilterContext *bitstream_filters;
269268 /* video only */
270269 int video_resample;
271270 AVFrame pict_tmp; /* temporary image for resampling */
@@ -572,7 +571,6 @@ static int ffmpeg_exit(int ret) · 300 unmodified lines
572571 }
573572 av_metadata_free(&s->metadata);
574573 av_free(s);
575− av_free(bitstream_filters[i]);
576574 av_free(output_streams_for_file[i]);
577575 }
578576 for(i=0;i<nb_input_files;i++) {
@@ -967,7 +965,7 @@ need_realloc: · 388 unmodified lines
967965 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
968966 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
969967 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);
971969
972970 ost->sync_opts += enc->frame_size;
973971 }
@@ -1002,7 +1000,7 @@ need_realloc: · 28 unmodified lines
10021000 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
10031001 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
10041002 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);
10061004 }
10071005 }
10081006
@@ -1107,7 +1105,7 @@ static void do_subtitle_out(AVFormatContext *s, · 98 unmodified lines
11071105 else
11081106 pkt.pts += 90 * sub->end_display_time;
11091107 }
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);
11111109 }
11121110 }
11131111
@@ -1267,7 +1265,7 @@ static void do_video_out(AVFormatContext *s, · 153 unmodified lines
12671265 pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
12681266 pkt.flags |= AV_PKT_FLAG_KEY;
12691267
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);
12711269 enc->coded_frame = old_frame;
12721270 } else {
12731271 AVFrame big_picture;
@@ -1311,7 +1309,7 @@ static void do_video_out(AVFormatContext *s, · 37 unmodified lines
13111309
13121310 if(enc->coded_frame->key_frame)
13131311 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);
13151313 *frame_size = ret;
13161314 video_size += ret;
13171315 //fprintf(stderr,"\nFrame: %3d size: %5d type: %d",
@@ -1766,7 +1764,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 448 unmodified lines
17661764 opkt.size = data_size;
17671765 }
17681766
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);
17701768 ost->st->codec->frame_number++;
17711769 ost->frame_number++;
17721770 av_free_packet(&opkt);
@@ -1875,7 +1873,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 102 unmodified lines
18751873 pkt.size= ret;
18761874 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
18771875 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);
18791877 }
18801878 }
18811879 }
@@ -3401,11 +3399,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx) · 1519 unmodified lines
34013399 }
34023400
34033401 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;
34093403 video_bitstream_filters= NULL;
34103404
34113405 avcodec_thread_init(st->codec, thread_count);
@@ -3548,11 +3542,7 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) · 136 unmodified lines
35483542
35493543 avcodec_get_context_defaults3(st->codec, codec);
35503544
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;
35563546 audio_bitstream_filters= NULL;
35573547
35583548 avcodec_thread_init(st->codec, thread_count);
@@ -3622,11 +3612,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) · 63 unmodified lines
36223612 }
36233613 avcodec_get_context_defaults3(st->codec, codec);
36243614
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;
36303616 subtitle_bitstream_filters= NULL;
36313617
36323618 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