[FFmpeg-devel,1/2] avcodec/v210dec: move DSP function setting into dedicated function

Submitted by James Darnley on March 4, 2019, 10:58 p.m.

Details

Message ID 20190304225851.17364-1-jdarnley@obe.tv
State New
Headers show

Commit Message

James Darnley March 4, 2019, 10:58 p.m.
Prepare for checkasm test.
---
 libavcodec/v210dec.c | 13 +++++++++----
 libavcodec/v210dec.h |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

Comments

Carl Eugen Hoyos March 6, 2019, 8:20 a.m.
2019-03-04 23:58 GMT+01:00, James Darnley <jdarnley@obe.tv>:
> Prepare for checkasm test.
> ---
>  libavcodec/v210dec.c | 13 +++++++++----
>  libavcodec/v210dec.h |  1 +
>  2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
> index ddc5dbe8be..28cf00d320 100644
> --- a/libavcodec/v210dec.c
> +++ b/libavcodec/v210dec.c
> @@ -50,6 +50,14 @@ static void v210_planar_unpack_c(const uint32_t *src,
> uint16_t *y, uint16_t *u,
>      }
>  }
>
> +av_cold void ff_v210dec_init(V210DecContext *s)
> +{
> +    s->unpack_frame = v210_planar_unpack_c;

> +    s->aligned_input = 0;

Isn't this an unrelated change or do I misunderstand?

Carl Eugen
Paul B Mahol March 6, 2019, 9:11 a.m.
On 3/6/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
> 2019-03-04 23:58 GMT+01:00, James Darnley <jdarnley@obe.tv>:
>> Prepare for checkasm test.
>> ---
>>  libavcodec/v210dec.c | 13 +++++++++----
>>  libavcodec/v210dec.h |  1 +
>>  2 files changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
>> index ddc5dbe8be..28cf00d320 100644
>> --- a/libavcodec/v210dec.c
>> +++ b/libavcodec/v210dec.c
>> @@ -50,6 +50,14 @@ static void v210_planar_unpack_c(const uint32_t *src,
>> uint16_t *y, uint16_t *u,
>>      }
>>  }
>>
>> +av_cold void ff_v210dec_init(V210DecContext *s)
>> +{
>> +    s->unpack_frame = v210_planar_unpack_c;
>
>> +    s->aligned_input = 0;
>
> Isn't this an unrelated change or do I misunderstand?

You misunderstand.
James Darnley March 6, 2019, 3:46 p.m.
On 2019-03-06 10:11, Paul B Mahol wrote:
> On 3/6/19, Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>> 2019-03-04 23:58 GMT+01:00, James Darnley <jdarnley@obe.tv>:
>>> Prepare for checkasm test.
>>> ---
>>>  libavcodec/v210dec.c | 13 +++++++++----
>>>  libavcodec/v210dec.h |  1 +
>>>  2 files changed, 10 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
>>> index ddc5dbe8be..28cf00d320 100644
>>> --- a/libavcodec/v210dec.c
>>> +++ b/libavcodec/v210dec.c
>>> @@ -50,6 +50,14 @@ static void v210_planar_unpack_c(const uint32_t *src,
>>> uint16_t *y, uint16_t *u,
>>>      }
>>>  }
>>>
>>> +av_cold void ff_v210dec_init(V210DecContext *s)
>>> +{
>>> +    s->unpack_frame = v210_planar_unpack_c;
>>
>>> +    s->aligned_input = 0;
>>
>> Isn't this an unrelated change or do I misunderstand?
> 
> You misunderstand.

Maybe.

I need to initialize that member before it is used in the x86 function.
I expect valgrind or similar would catch the use.

It doesn't matter for normal use because it will be set correctly based
on the input data alignment for each frame.  Now that you mention it I
realize I forgot to change that to call the new function so I will send
a v2 later.

Patch hide | download patch | download mbox

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index ddc5dbe8be..28cf00d320 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -50,6 +50,14 @@  static void v210_planar_unpack_c(const uint32_t *src, uint16_t *y, uint16_t *u,
     }
 }
 
+av_cold void ff_v210dec_init(V210DecContext *s)
+{
+    s->unpack_frame = v210_planar_unpack_c;
+    s->aligned_input = 0;
+    if (ARCH_X86)
+        ff_v210_x86_init(s);
+}
+
 static av_cold int decode_init(AVCodecContext *avctx)
 {
     V210DecContext *s = avctx->priv_data;
@@ -57,10 +65,7 @@  static av_cold int decode_init(AVCodecContext *avctx)
     avctx->pix_fmt             = AV_PIX_FMT_YUV422P10;
     avctx->bits_per_raw_sample = 10;
 
-    s->unpack_frame            = v210_planar_unpack_c;
-
-    if (HAVE_MMX)
-        ff_v210_x86_init(s);
+    ff_v210dec_init(s);
 
     return 0;
 }
diff --git a/libavcodec/v210dec.h b/libavcodec/v210dec.h
index 533afc435c..cfdb29da09 100644
--- a/libavcodec/v210dec.h
+++ b/libavcodec/v210dec.h
@@ -31,6 +31,7 @@  typedef struct {
     void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width);
 } V210DecContext;
 
+void ff_v210dec_init(V210DecContext *s);
 void ff_v210_x86_init(V210DecContext *s);
 
 #endif /* AVCODEC_V210DEC_H */