static int filter_packet(void *log_ctx, AVPacket *pkt,

                         AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx)

{

    AVCodecContext *enc_ctx = fmt_ctx->streams[pkt->stream_index]->codec;

    int ret;



    while (bsf_ctx) {

        AVPacket new_pkt = *pkt;

        ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL,

                                             &new_pkt.data, &new_pkt.size,

                                             pkt->data, pkt->size,

                                             pkt->flags & AV_PKT_FLAG_KEY);

        if (ret == 0 && new_pkt.data != pkt->data && new_pkt.destruct) {

            if ((ret = av_copy_packet(&new_pkt, pkt)) < 0)

                break;

            ret = 1;

        }



        if (ret > 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)

                break;

        }

        *pkt = new_pkt;



        bsf_ctx = bsf_ctx->next;

    }



    if (ret < 0) {

        av_log(log_ctx, AV_LOG_ERROR,

               "Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n",

               bsf_ctx->filter->name, pkt->stream_index, fmt_ctx->filename,

               avcodec_get_name(enc_ctx->codec_id));

    }



    return ret;

}

static int filter_packet(void *log_ctx, AVPacket *pkt,

                         AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx)

{

    AVCodecContext *enc_ctx = fmt_ctx->streams[pkt->stream_index]->codec;

    int ret;



    while (bsf_ctx) {

        AVPacket new_pkt = *pkt;

        ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL,

                                             &new_pkt.data, &new_pkt.size,

                                             pkt->data, pkt->size,

                                             pkt->flags & AV_PKT_FLAG_KEY);

        if (ret == 0 && new_pkt.data != pkt->data && new_pkt.destruct) {

            if ((ret = av_copy_packet(&new_pkt, pkt)) < 0)

                break;

            ret = 1;

        }



        if (ret > 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)

                break;

        }

        *pkt = new_pkt;



        bsf_ctx = bsf_ctx->next;

    }



    if (ret < 0) {

        av_log(log_ctx, AV_LOG_ERROR,

               "Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n",

               bsf_ctx->filter->name, pkt->stream_index, fmt_ctx->filename,

               avcodec_get_name(enc_ctx->codec_id));

    }



    return ret;

}

    int ret;
static int FUNC_0(void *VAR_0, AVPacket *VAR_1,

                         AVFormatContext *VAR_2, AVBitStreamFilterContext *VAR_3)

{

    AVCodecContext *enc_ctx = VAR_2->streams[VAR_1->stream_index]->codec;

    int VAR_4;



    while (VAR_3) {

        AVPacket new_pkt = *VAR_1;

        VAR_4 = av_bitstream_filter_filter(VAR_3, enc_ctx, NULL,

                                             &new_pkt.data, &new_pkt.size,

                                             VAR_1->data, VAR_1->size,

                                             VAR_1->flags & AV_PKT_FLAG_KEY);

        if (VAR_4 == 0 && new_pkt.data != VAR_1->data && new_pkt.destruct) {

            if ((VAR_4 = av_copy_packet(&new_pkt, VAR_1)) < 0)

                break;

            VAR_4 = 1;

        }



        if (VAR_4 > 0) {

            av_free_packet(VAR_1);

            new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,

                                           av_buffer_default_free, NULL, 0);

            if (!new_pkt.buf)

                break;

        }

        *VAR_1 = new_pkt;



        VAR_3 = VAR_3->next;

    }



    if (VAR_4 < 0) {

        av_log(VAR_0, AV_LOG_ERROR,

               "Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n",

               VAR_3->filter->name, VAR_1->stream_index, VAR_2->filename,

               avcodec_get_name(enc_ctx->codec_id));

    }



    return VAR_4;

}

static int FUNC_0(void *VAR_0, AVPacket *VAR_1,
AVFormatContext *VAR_2, AVBitStreamFilterContext *VAR_3)
{ AVCodecContext *enc_ctx = VAR_2->streams[VAR_1->stream_index]->codec; int VAR_4; while (VAR_3) { AVPacket new_pkt = *VAR_1; VAR_4 = av_bitstream_filter_filter(VAR_3, enc_ctx, NULL,
&new_pkt.data, &new_pkt.size,
VAR_1->data, VAR_1->size,
VAR_1->flags & AV_PKT_FLAG_KEY); if (VAR_4 == 0 && new_pkt.data != VAR_1->data && new_pkt.destruct) { if ((VAR_4 = av_copy_packet(&new_pkt, VAR_1)) < 0)
break; VAR_4 = 1; } if (VAR_4 > 0) { av_free_packet(VAR_1); new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
av_buffer_default_free, NULL, 0); if (!new_pkt.buf)
break; } *VAR_1 = new_pkt; VAR_3 = VAR_3->next; } if (VAR_4 < 0) { av_log(VAR_0, AV_LOG_ERROR,
"Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n",
VAR_3->filter->name, VAR_1->stream_index, VAR_2->filename,
avcodec_get_name(enc_ctx->codec_id)); } return VAR_4; }