[FFmpeg-devel] [PATCH] avformat/mxfenc: support XAVC long gop

James Almer jamrial at gmail.com
Thu Apr 11 01:16:14 EEST 2019


On 4/10/2019 6:23 PM, Baptiste Coudurier wrote:
> ---
>  libavformat/Makefile |   2 +-
>  libavformat/avc.c    | 173 +++++++++++++++++++++++++++++++++++
>  libavformat/avc.h    |  15 +++
>  libavformat/hevc.c   |  36 +-------
>  libavformat/mxf.h    |   1 +
>  libavformat/mxfenc.c | 213 ++++++++++++++++++++++++++++++++++---------
>  6 files changed, 359 insertions(+), 81 deletions(-)
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 99be60d184..df87c54a58 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -339,7 +339,7 @@ OBJS-$(CONFIG_MUSX_DEMUXER)              += musx.o
>  OBJS-$(CONFIG_MV_DEMUXER)                += mvdec.o
>  OBJS-$(CONFIG_MVI_DEMUXER)               += mvi.o
>  OBJS-$(CONFIG_MXF_DEMUXER)               += mxfdec.o mxf.o
> -OBJS-$(CONFIG_MXF_MUXER)                 += mxfenc.o mxf.o audiointerleave.o
> +OBJS-$(CONFIG_MXF_MUXER)                 += mxfenc.o mxf.o audiointerleave.o avc.o
>  OBJS-$(CONFIG_MXG_DEMUXER)               += mxg.o
>  OBJS-$(CONFIG_NC_DEMUXER)                += ncdec.o
>  OBJS-$(CONFIG_NISTSPHERE_DEMUXER)        += nistspheredec.o pcm.o
> diff --git a/libavformat/avc.c b/libavformat/avc.c
> index ec50033a04..06a1e495a8 100644
> --- a/libavformat/avc.c
> +++ b/libavformat/avc.c
> @@ -21,6 +21,7 @@
>  
>  #include "libavutil/intreadwrite.h"
>  #include "libavcodec/h264.h"
> +#include "libavcodec/golomb.h"

Right, so golomb has a bunch of lookup tables in golomb.c, obviously not
accessible from libavformat. So this will probably fail to build in
shared builds.

One option is to include golomb.c here. Another is donig with it the
same we're doing with libavutil's log2_tab.c, and the other is to write
simple get_se() and get_ue() functions here that don't use lookup tables.

Something like (untested)

static int get_ue_golomb(GetBitContext *gb)
{
    int i, j, k, v;

    for (i = 0; i < 32; i++) {
        k = get_bits1(gbc);
        if (k)
            break;
    }
    v = 1;
    for (j = 0; j < i; j++) {
        k = get_bits1(gbc);
        v = v << 1 | k;
    }
    --v;

    return v;
}

static int get_se_golomb(GetBitContext *gb)
{
    int i, j, k, v;

    for (i = 0; i < 32; i++) {
        k = get_bits1(gbc);
        if (k)
            break;
    }
    v = 1;
    for (j = 0; j < i; j++) {
        k = get_bits1(gbc);
        v = v << 1 | k;
    }
    if (v & 1)
        v = -(int32_t)(v / 2);
    else
        v = v / 2;

    return v;
}


More information about the ffmpeg-devel mailing list