[FFmpeg-devel] [PATCH 3/6] ffmpeg: use lavf API for applying bitstream filters

Michael Niedermayer michael at niedermayer.cc
Thu Oct 8 11:41:01 CEST 2015


On Wed, Oct 07, 2015 at 09:50:04PM -0500, Rodger Combs wrote:
> ---
>  ffmpeg.c     | 46 ++++------------------------------------------
>  ffmpeg.h     |  1 -
>  ffmpeg_opt.c |  6 +++++-
>  3 files changed, 9 insertions(+), 44 deletions(-)
> 
> diff --git a/ffmpeg.c b/ffmpeg.c
> index e31a2c6..b9cde79 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -682,47 +682,10 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
>      if (bsfc)
>          av_packet_split_side_data(pkt);
>  
> -    while (bsfc) {
> -        AVPacket new_pkt = *pkt;
> -        AVDictionaryEntry *bsf_arg = av_dict_get(ost->bsf_args,
> -                                                 bsfc->filter->name,
> -                                                 NULL, 0);
> -        int a = av_bitstream_filter_filter(bsfc, avctx,
> -                                           bsf_arg ? bsf_arg->value : NULL,
> -                                           &new_pkt.data, &new_pkt.size,
> -                                           pkt->data, pkt->size,
> -                                           pkt->flags & AV_PKT_FLAG_KEY);
> -        if(a == 0 && new_pkt.data != pkt->data) {
> -            uint8_t *t = av_malloc(new_pkt.size + AV_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so cannot overflow
> -            if(t) {
> -                memcpy(t, new_pkt.data, new_pkt.size);
> -                memset(t + new_pkt.size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
> -                new_pkt.data = t;
> -                new_pkt.buf = NULL;
> -                a = 1;
> -            } else
> -                a = AVERROR(ENOMEM);
> -        }
> -        if (a > 0) {
> -            pkt->side_data = NULL;
> -            pkt->side_data_elems = 0;
> -            av_free_packet(pkt);
> -            new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
> -                                           av_buffer_default_free, NULL, 0);
> -            if (!new_pkt.buf)
> -                exit_program(1);
> -        } else if (a < 0) {
> -            new_pkt = *pkt;
> -            av_log(NULL, AV_LOG_ERROR, "Failed to open bitstream filter %s for stream %d with codec %s",
> -                   bsfc->filter->name, pkt->stream_index,
> -                   avctx->codec ? avctx->codec->name : "copy");
> -            print_error("", a);
> -            if (exit_on_error)
> -                exit_program(1);
> -        }
> -        *pkt = new_pkt;
> -
> -        bsfc = bsfc->next;

> +    if (ret = av_apply_bitstream_filters(s, pkt, bsfc) < 0) {

this is missing ()

> +        print_error("", ret);

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151008/f1a4cc83/attachment.sig>


More information about the ffmpeg-devel mailing list