[FFmpeg-devel] [PATCH 1/2] spdifenc: IEC 61937 encapsulation of DTS-HD for HDMI

Anssi Hannula anssi.hannula
Thu Jan 27 21:05:55 CET 2011


On 27.01.2011 21:06, M?ns Rullg?rd wrote:
> Anssi Hannula <anssi.hannula at iki.fi> writes:
> 
>> On 27.01.2011 19:50, Justin Ruggles wrote:
>>> Hi,
>>
>> Hi!
>>
>>> On 01/21/2011 01:32 PM, Anssi Hannula wrote:
>>>
>>>> ---
>>>>
>>>> This time the default mode of operation is to passthrough DTS-core only
>>>> unless the HD mode is explicitely requested by the user via an AVOption.
>>>>
>>>> This way we avoid exporting the final bitrate in avctx->bit_rate as I
>>>> previously planned, as now the caller always specifies the output rate
>>>> themselves and therefore already knows the output rate (as is the case
>>>> for other formats as well).
>>>>
>>>> An AVOption is used instead of the previously planned muxrate as the
>>>> usage doesn't exactly match muxrate semantics.
>>>>
>>>>  Changelog              |    2 +-
>>>>  libavformat/avformat.h |    2 +-
>>>>  libavformat/spdifenc.c |  147 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>>  3 files changed, 149 insertions(+), 2 deletions(-)
>>>>
>>>> +static int spdif_header_dts4(AVFormatContext *s, AVPacket *pkt, int core_size,
>>>> +                             int sample_rate, int blocks)
>>>> +{
>>>> +    IEC61937Context *ctx = s->priv_data;
>>>> +    const char dtshd_start_code[10] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe };
>>>
>>>
>>> dtshd_start_code could be made static.
>>
>> Hm, what difference would it make?
>>
>> Since it is a constant, the values are retained over calls by definition
>> even without "static" keyword, and indeed there seems to be no
>> difference between "const" or "static const" inside a function in output
>> of gcc.
> 
> It does make a difference:

Ah, indeed, there was a typo in my test.
I'll add "static" to the patch.

But is there any reason to ever not declare const arrays in function
context as "static const", then?


> ---8<---
> int baz(const char *);
> 
> int foo(void)
> {
>     const char x[] = { 1, 2, 3, 4 };
>     return baz(x);
> }
> 
> int bar(void)
> {
>     static const char x[] = { 1, 2, 3, 4 };
>     return baz(x);
> }
> --->8---
> 
> Disassembly of section .text:
> 
> 00000000 <foo>:
>    0:   e52de004        push    {lr}            ; (str lr, [sp, #-4]!)
>    4:   e59f301c        ldr     r3, [pc, #28]   ; 28 <foo+0x28>
>    8:   e24dd00c        sub     sp, sp, #12
>    c:   e5933000        ldr     r3, [r3]
>   10:   e28d0008        add     r0, sp, #8
>   14:   e5203004        str     r3, [r0, #-4]!
>   18:   ebfffffe        bl      0 <baz>
>   1c:   e28dd00c        add     sp, sp, #12
>   20:   e49de004        pop     {lr}            ; (ldr lr, [sp], #4)
>   24:   e12fff1e        bx      lr
>   28:   00000000        .word   0x00000000
> 
> 0000002c <bar>:
>   2c:   e92d4008        push    {r3, lr}
>   30:   e59f0008        ldr     r0, [pc, #8]    ; 40 <bar+0x14>
>   34:   ebfffffe        bl      0 <baz>
>   38:   e8bd4008        pop     {r3, lr}
>   3c:   e12fff1e        bx      lr
>   40:   00000004        .word   0x00000004
> 


-- 
Anssi Hannula



More information about the ffmpeg-devel mailing list