[FFmpeg-devel] [PATCH] Allow bit stream filters to be applied?to input
Michael Niedermayer
michaelni
Tue May 5 13:38:20 CEST 2009
On Tue, May 05, 2009 at 07:15:10PM +1200, Paul Kendall wrote:
> On Monday 04 May 2009 10:34:33 pm Michael Niedermayer wrote:
> > On Mon, May 04, 2009 at 04:43:45PM +1200, Paul Kendall wrote:
> > > This patch allows the -absf, -vbsf & -sbsf to be applied to ffmpeg input
> > > files. The bitstream filter will be applied before decoding.
> > >
> > > Comments welcome.
> >
> > [...]
> >
> > > @@ -502,9 +503,7 @@
> > > return (double)(ist->pts - start_time)/AV_TIME_BASE;
> > > }
> > >
> > > -static void write_frame(AVFormatContext *s, AVPacket *pkt,
> > > AVCodecContext *avctx, AVBitStreamFilterContext *bsfc){ - int ret;
> > > -
> > > +static void apply_filters(AVPacket *pkt, AVCodecContext *avctx,
> > > AVBitStreamFilterContext *bsfc){ while(bsfc){
> > > AVPacket new_pkt= *pkt;
> > > int a= av_bitstream_filter_filter(bsfc, avctx, NULL,
> > > @@ -526,7 +525,13 @@
> > >
> > > bsfc= bsfc->next;
> > > }
> > > +}
> > >
> > > +static void write_frame(AVFormatContext *s, AVPacket *pkt,
> > > AVCodecContext *avctx, AVBitStreamFilterContext *bsfc){ + int ret;
> > > +
> > > + apply_filters(pkt, avctx, bsfc);
> > > +
> > > ret= av_interleaved_write_frame(s, pkt);
> > > if(ret < 0){
> > > print_error("av_interleaved_write_frame()", ret);
> >
> > factorizing out apply_filters() should be a seperate patch
> >
> > > @@ -702,7 +707,7 @@
> > > if(enc->coded_frame && enc->coded_frame->pts !=
> > > AV_NOPTS_VALUE) pkt.pts= av_rescale_q(enc->coded_frame->pts,
> > > enc->time_base, ost->st->time_base); pkt.flags |= PKT_FLAG_KEY;
> > > - write_frame(s, &pkt, ost->st->codec,
> > > bitstream_filters[ost->file_index][pkt.stream_index]); +
> > > write_frame(s, &pkt, ost->st->codec,
> > > output_bitstream_filters[ost->file_index][pkt.stream_index]);
> > >
> > > ost->sync_opts += enc->frame_size;
> > > }
> >
> > renaming variables should also be a seperate patch
> >
> >
> > [...]
> >
> > > @@ -1219,6 +1224,9 @@
> > > if(avpkt.size && avpkt.size != pkt->size && verbose>0)
> > > fprintf(stderr, "Multiple frames in a packet from stream
> > > %d\n", pkt->stream_index);
> > >
> > > + /* apply bitstream filters */
> > > + apply_filters(&avpkt, ist->st->codec,
> > > input_bitstream_filters[ist->file_index][ist_index]); +
> > > /* decode the packet if needed */
> > > data_buf = NULL; /* fail safe */
> > > data_size = 0;
> >
> > trailing whitespace is forbidden in svn
> >
> >
> >
> > [...]
> Problems addressed, new separate patches attached.
>
> Cheers,
> Paul
>
> ffmpeg.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
> a3332d4920924438518f0f2cabd03a90cb57db3b ffmpeg.1.variable-rename.patch
ok
[...]
> ffmpeg.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
> b5ae2d6dc2e813757252fc68ce2aa3fd6d22b84b ffmpeg.2.apply-filters-splitout.patch
ok
[...]
> ffmpeg.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
> 296265240c559a0bde0aa36dfef709e17a7224aa ffmpeg.3.input-filtering.patch
> --- ffmpeg.c.apply 2009-05-05 19:08:38.000000000 +1200
> +++ ffmpeg.c 2009-05-05 19:09:13.000000000 +1200
> @@ -232,6 +232,7 @@
> static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
> static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL;
> static AVBitStreamFilterContext *output_bitstream_filters[MAX_FILES][MAX_STREAMS];
> +static AVBitStreamFilterContext *input_bitstream_filters[MAX_FILES][MAX_STREAMS];
>
> #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
>
> @@ -1223,6 +1224,9 @@
> if(avpkt.size && avpkt.size != pkt->size && verbose>0)
> fprintf(stderr, "Multiple frames in a packet from stream %d\n", pkt->stream_index);
>
> + /* apply bitstream filters */
> + apply_filters(&avpkt, ist->st->codec, input_bitstream_filters[ist->file_index][ist_index]);
the comment seems redundant
> +
> /* decode the packet if needed */
> data_buf = NULL; /* fail safe */
> data_size = 0;
> @@ -1230,8 +1234,8 @@
> if (ist->decoding_needed) {
> switch(ist->st->codec->codec_type) {
> case CODEC_TYPE_AUDIO:{
> - if(pkt && samples_size < FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
> - samples_size = FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
> + if(pkt && samples_size < FFMAX(avpkt.size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
> + samples_size = FFMAX(avpkt.size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
> av_free(samples);
> samples= av_malloc(samples_size);
> }
is this a seperate bugfix? if so it should be in a seperate patch
also this patch should be tested to make sure mixing input & output filters as
well as several input & output files & streams work
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090505/03c6a97d/attachment.pgp>
More information about the ffmpeg-devel
mailing list