diff mbox

[FFmpeg-devel,03/11] avcodec/mdec: override IDCT choice before initing DSP structs

Message ID 20170619151104.31273-4-jdarnley@obe.tv
State Accepted
Commit 9d11fedd1129565c8ba9e90b08b43e06f441b4fb
Headers show

Commit Message

James Darnley June 19, 2017, 3:10 p.m. UTC
---
 libavcodec/mdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Ronald S. Bultje June 19, 2017, 6:05 p.m. UTC | #1
Hi,

On Mon, Jun 19, 2017 at 11:10 AM, James Darnley <jdarnley@obe.tv> wrote:

> ---
>  libavcodec/mdec.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
> index 8e28aa04f0..97bfebbeb7 100644
> --- a/libavcodec/mdec.c
> +++ b/libavcodec/mdec.c
> @@ -213,6 +213,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  {
>      MDECContext * const a = avctx->priv_data;
>
> +    if (avctx->idct_algo == FF_IDCT_AUTO)
> +        avctx->idct_algo = FF_IDCT_SIMPLE;
> +
>      a->mb_width  = (avctx->coded_width  + 15) / 16;
>      a->mb_height = (avctx->coded_height + 15) / 16;
>
> @@ -225,8 +228,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
>      ff_init_scantable(a->idsp.idct_permutation, &a->scantable,
>                        ff_zigzag_direct);
>
> -    if (avctx->idct_algo == FF_IDCT_AUTO)
> -        avctx->idct_algo = FF_IDCT_SIMPLE;
>      avctx->pix_fmt  = AV_PIX_FMT_YUVJ420P;
>      avctx->color_range = AVCOL_RANGE_JPEG;
>
> --
> 2.13.1


Can we use per-codec defaults to accomplish this?

So add an AVClass as first member here and use that to set its defaults
member to a AVCodecDefault defaults[] array which has one entry: { "idct",
"simple" }.

Ronald
Ronald S. Bultje June 20, 2017, noon UTC | #2
Hi,

On Mon, Jun 19, 2017 at 2:05 PM, Ronald S. Bultje <rsbultje@gmail.com>
wrote:

> Hi,
>
> On Mon, Jun 19, 2017 at 11:10 AM, James Darnley <jdarnley@obe.tv> wrote:
>
>> ---
>>  libavcodec/mdec.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
>> index 8e28aa04f0..97bfebbeb7 100644
>> --- a/libavcodec/mdec.c
>> +++ b/libavcodec/mdec.c
>> @@ -213,6 +213,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
>>  {
>>      MDECContext * const a = avctx->priv_data;
>>
>> +    if (avctx->idct_algo == FF_IDCT_AUTO)
>> +        avctx->idct_algo = FF_IDCT_SIMPLE;
>> +
>>      a->mb_width  = (avctx->coded_width  + 15) / 16;
>>      a->mb_height = (avctx->coded_height + 15) / 16;
>>
>> @@ -225,8 +228,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
>>      ff_init_scantable(a->idsp.idct_permutation, &a->scantable,
>>                        ff_zigzag_direct);
>>
>> -    if (avctx->idct_algo == FF_IDCT_AUTO)
>> -        avctx->idct_algo = FF_IDCT_SIMPLE;
>>      avctx->pix_fmt  = AV_PIX_FMT_YUVJ420P;
>>      avctx->color_range = AVCOL_RANGE_JPEG;
>>
>> --
>> 2.13.1
>
>
> Can we use per-codec defaults to accomplish this?
>

I'm not actually sure this is a good idea, because it changes the meaning
of _AUTO slightly. Patch is OK as-is.

Ronald
diff mbox

Patch

diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index 8e28aa04f0..97bfebbeb7 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -213,6 +213,9 @@  static av_cold int decode_init(AVCodecContext *avctx)
 {
     MDECContext * const a = avctx->priv_data;
 
+    if (avctx->idct_algo == FF_IDCT_AUTO)
+        avctx->idct_algo = FF_IDCT_SIMPLE;
+
     a->mb_width  = (avctx->coded_width  + 15) / 16;
     a->mb_height = (avctx->coded_height + 15) / 16;
 
@@ -225,8 +228,6 @@  static av_cold int decode_init(AVCodecContext *avctx)
     ff_init_scantable(a->idsp.idct_permutation, &a->scantable,
                       ff_zigzag_direct);
 
-    if (avctx->idct_algo == FF_IDCT_AUTO)
-        avctx->idct_algo = FF_IDCT_SIMPLE;
     avctx->pix_fmt  = AV_PIX_FMT_YUVJ420P;
     avctx->color_range = AVCOL_RANGE_JPEG;