avcodec: Make sure codec_type is set by avcodec_get_context_defaults2

Message ID 1320313295-16505-1-git-send-email-martin@martin.st
State Committed
Commit cae4f4b77e7dc037ad5dfcc7bc636788f1420ba9
Headers show

Commit Message

Martin Storsjö Nov. 3, 2011, 9:41 a.m.
This function used to set codec_type. With the current fallback
implementation based on avcodec_get_context_defaults3, codec_type
won't be set to the value passed in, but will be set to
AVMEDIA_TYPE_UNKNOWN. Legacy callers of this function might expect
this field to be set to the value passed in.
---
 libavcodec/options.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Anton Khirnov Nov. 3, 2011, 11:28 a.m. | #1
On Thu,  3 Nov 2011 11:41:35 +0200, Martin Storsjö <martin@martin.st> wrote:
> This function used to set codec_type. With the current fallback
> implementation based on avcodec_get_context_defaults3, codec_type
> won't be set to the value passed in, but will be set to
> AVMEDIA_TYPE_UNKNOWN. Legacy callers of this function might expect
> this field to be set to the value passed in.
> ---
>  libavcodec/options.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/libavcodec/options.c b/libavcodec/options.c
> index fdc8a71..a08ed98 100644
> --- a/libavcodec/options.c
> +++ b/libavcodec/options.c
> @@ -539,6 +539,7 @@ static const AVClass av_codec_context_class = {
>  #if FF_API_ALLOC_CONTEXT
>  void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){
>      avcodec_get_context_defaults3(s, NULL);
> +    s->codec_type = codec_type;
>  }
>  #endif
>  
> -- 
> 1.7.3.1
> 

Ok

Patch

diff --git a/libavcodec/options.c b/libavcodec/options.c
index fdc8a71..a08ed98 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -539,6 +539,7 @@  static const AVClass av_codec_context_class = {
 #if FF_API_ALLOC_CONTEXT
 void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){
     avcodec_get_context_defaults3(s, NULL);
+    s->codec_type = codec_type;
 }
 #endif