libopenh264dec: Export the decoded profile and level in AVCodecContext

Message ID 20180831092559.76116-1-martin@martin.st
State New
Headers show
Series
  • libopenh264dec: Export the decoded profile and level in AVCodecContext
Related show

Commit Message

Martin Storsjö Aug. 31, 2018, 9:25 a.m.
---
 libavcodec/libopenh264dec.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Vittorio Giovara Aug. 31, 2018, 9:44 a.m. | #1
On Fri, Aug 31, 2018 at 11:25 AM, Martin Storsjö <martin@martin.st> wrote:

> ---
>  libavcodec/libopenh264dec.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
> index 5990a72ff9..7e9e66743a 100644
> --- a/libavcodec/libopenh264dec.c
> +++ b/libavcodec/libopenh264dec.c
> @@ -95,6 +95,7 @@ static int svc_decode_frame(AVCodecContext *avctx, void
> *data,
>      int linesize[3];
>      AVFrame *avframe = data;
>      DECODING_STATE state;
> +    int opt;
>
>      if (!avpkt->data) {
>  #if OPENH264_VER_AT_LEAST(1, 9)
> @@ -136,6 +137,10 @@ FF_DISABLE_DEPRECATION_WARNINGS
>      avframe->pkt_pts = avpkt->pts;
>  FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
> +    (*s->decoder)->GetOption(s->decoder, DECODER_OPTION_PROFILE, &opt);
> +    avctx->profile = opt;
> +    (*s->decoder)->GetOption(s->decoder, DECODER_OPTION_LEVEL, &opt);
> +    avctx->level = opt;
>
>      *got_frame = 1;
>      return avpkt->size;
> --
>

lgtm
Martin Storsjö Aug. 31, 2018, 10:30 a.m. | #2
On Fri, 31 Aug 2018, Vittorio Giovara wrote:

> On Fri, Aug 31, 2018 at 11:25 AM, Martin Storsjö <martin@martin.st> wrote:
>
>> ---
>>  libavcodec/libopenh264dec.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
>> index 5990a72ff9..7e9e66743a 100644
>> --- a/libavcodec/libopenh264dec.c
>> +++ b/libavcodec/libopenh264dec.c
>> @@ -95,6 +95,7 @@ static int svc_decode_frame(AVCodecContext *avctx, void
>> *data,
>>      int linesize[3];
>>      AVFrame *avframe = data;
>>      DECODING_STATE state;
>> +    int opt;
>>
>>      if (!avpkt->data) {
>>  #if OPENH264_VER_AT_LEAST(1, 9)
>> @@ -136,6 +137,10 @@ FF_DISABLE_DEPRECATION_WARNINGS
>>      avframe->pkt_pts = avpkt->pts;
>>  FF_ENABLE_DEPRECATION_WARNINGS
>>  #endif
>> +    (*s->decoder)->GetOption(s->decoder, DECODER_OPTION_PROFILE, &opt);
>> +    avctx->profile = opt;
>> +    (*s->decoder)->GetOption(s->decoder, DECODER_OPTION_LEVEL, &opt);
>> +    avctx->level = opt;
>>
>>      *got_frame = 1;
>>      return avpkt->size;
>> --
>>
>
> lgtm

Thanks - pushed with appropriate openh264 version ifdefs added.

// Martin

Patch

diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
index 5990a72ff9..7e9e66743a 100644
--- a/libavcodec/libopenh264dec.c
+++ b/libavcodec/libopenh264dec.c
@@ -95,6 +95,7 @@  static int svc_decode_frame(AVCodecContext *avctx, void *data,
     int linesize[3];
     AVFrame *avframe = data;
     DECODING_STATE state;
+    int opt;
 
     if (!avpkt->data) {
 #if OPENH264_VER_AT_LEAST(1, 9)
@@ -136,6 +137,10 @@  FF_DISABLE_DEPRECATION_WARNINGS
     avframe->pkt_pts = avpkt->pts;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
+    (*s->decoder)->GetOption(s->decoder, DECODER_OPTION_PROFILE, &opt);
+    avctx->profile = opt;
+    (*s->decoder)->GetOption(s->decoder, DECODER_OPTION_LEVEL, &opt);
+    avctx->level = opt;
 
     *got_frame = 1;
     return avpkt->size;