[FFmpeg-devel] [PATCH] omx: Add support for specifying H.264 profile [v5]

Michael Niedermayer michael at niedermayer.cc
Fri Mar 3 01:58:13 EET 2017


On Wed, Mar 01, 2017 at 05:42:29AM +0900, Takayuki 'January June' Suwa wrote:
> From: Takayuki 'January June' Suwa <jjsuwa at users.noreply.github.com>
> 
> This adds "-profile[:v] profile_name"-style option.
> ---
>  libavcodec/omx.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/libavcodec/omx.c b/libavcodec/omx.c
> index 16df50e..c0d64e2 100644
> --- a/libavcodec/omx.c
> +++ b/libavcodec/omx.c
> @@ -226,6 +226,7 @@ typedef struct OMXCodecContext {
>      int output_buf_size;
>  
>      int input_zerocopy;
> +    int profile;
>  } OMXCodecContext;
>  
>  static void append_buffer(pthread_mutex_t *mutex, pthread_cond_t *cond,
> @@ -523,6 +524,34 @@ static av_cold int omx_component_init(AVCodecContext *avctx, const char *role)
>          CHECK(err);
>          avc.nBFrames = 0;
>          avc.nPFrames = avctx->gop_size - 1;
> +        switch (s->profile) {
> +        case FF_PROFILE_H264_BASELINE:
> +            avc.eProfile = OMX_VIDEO_AVCProfileBaseline;
> +            break;
> +        case FF_PROFILE_H264_MAIN:
> +            avc.eProfile = OMX_VIDEO_AVCProfileMain;
> +            break;
> +        case FF_PROFILE_H264_HIGH:
> +            avc.eProfile = OMX_VIDEO_AVCProfileHigh;
> +            break;
> +        default:
> +            break;
> +        case FF_PROFILE_UNKNOWN:
> +            switch (avctx->profile) {
> +            case FF_PROFILE_H264_BASELINE:
> +                avc.eProfile = OMX_VIDEO_AVCProfileBaseline;
> +                break;
> +            case FF_PROFILE_H264_MAIN:
> +                avc.eProfile = OMX_VIDEO_AVCProfileMain;
> +                break;
> +            case FF_PROFILE_H264_HIGH:
> +                avc.eProfile = OMX_VIDEO_AVCProfileHigh;
> +                break;
> +            default:
> +                break;
> +            }
> +            break;
> +        }
>          err = OMX_SetParameter(s->handle, OMX_IndexParamVideoAvc, &avc);
>          CHECK(err);
>      }
> @@ -884,6 +913,10 @@ static const AVOption options[] = {
>      { "omx_libname", "OpenMAX library name", OFFSET(libname), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },
>      { "omx_libprefix", "OpenMAX library prefix", OFFSET(libprefix), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VDE },
>      { "zerocopy", "Try to avoid copying input frames if possible", OFFSET(input_zerocopy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
> +    { "profile",  "Set the encoding profile", OFFSET(profile), AV_OPT_TYPE_INT,   { .i64 = FF_PROFILE_UNKNOWN },       FF_PROFILE_UNKNOWN, FF_PROFILE_H264_HIGH, VE, "profile" },

iam slightly confused

In libx264.c s->profile is a char*
here it is a int like AVCodecContext.profile

if you want to keep both as int, (to list the AVOptions the codec
supports?)
you could use a local variable to simplify the code:
int profile = s->profile == FF_PROFILE_UNKNOWN ? avctx->profile : s->profile

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

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- 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/20170303/f4c58bf8/attachment.sig>


More information about the ffmpeg-devel mailing list