[FFmpeg-devel] [PATCH 3/4] avcodec: add unpack packed B-frames bitstream filter

Michael Niedermayer michaelni at gmx.at
Sun Apr 5 00:06:26 CEST 2015


On Fri, Apr 03, 2015 at 07:14:58PM +0200, Andreas Cadhalpun wrote:
> Fixes Ticket #2913
> 
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> ---
>  Changelog                             |   1 +
>  doc/bitstream_filters.texi            |  20 ++++
>  libavcodec/Makefile                   |   1 +
>  libavcodec/allcodecs.c                |   1 +
>  libavcodec/mpeg4_unpack_bframes_bsf.c | 200 ++++++++++++++++++++++++++++++++++
>  libavcodec/version.h                  |   2 +-

>  patcheck.tmp                          |   0

this shouldnt be in there


[...]
> diff --git a/libavcodec/mpeg4_unpack_bframes_bsf.c b/libavcodec/mpeg4_unpack_bframes_bsf.c
> new file mode 100644
> index 0000000..977e5f0
> --- /dev/null
> +++ b/libavcodec/mpeg4_unpack_bframes_bsf.c
> @@ -0,0 +1,200 @@
> +/*
> + * Bitstream filter for unpacking DivX-style packed B-frames in MPEG-4 (divx_packed)
> + * Copyright (c) 2015 Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include "avcodec.h"
> +#include "get_bits.h"
> +#include "mpeg4video.h"
> +
> +typedef struct UnpackBFramesBSFContext {
> +    uint8_t *b_frame_buf;
> +    int      b_frame_buf_size;
> +    int      updated_extradata;
> +} UnpackBFramesBSFContext;
> +
> +/* search next start code */
> +static unsigned int find_startcode(GetBitContext *gb)
> +{
> +    unsigned int startcode;
> +    align_get_bits(gb);
> +    startcode = 0xFF;
> +
> +    for (; get_bits_count(gb) < gb->size_in_bits;) {
> +        startcode = ((startcode << 8) | get_bits(gb, 8)) & 0xFFFFFFFF;
> +        if ((startcode & 0xFFFFFF00) != 0x100)
> +            continue;  /* no startcode */
> +        return startcode;
> +    }
> +
> +    return 0;
> +}

no need to use GetBitContext for working with bytes
simple uint8_t should be faster
or libavcodec/bytestream.h could be used

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150405/0c079501/attachment.asc>


More information about the ffmpeg-devel mailing list