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

Måns Rullgård mans
Thu Jan 27 20:57:46 CET 2011


Jean-Daniel Dupas <devlists at shadowlab.org> writes:

> Le 27 janv. 2011 ? 20:06, M?ns Rullg?rd a ?crit :
>
>> 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:
>>>> 
>>>>> +    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:
>> 
>> ---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---
>> 
>
> I don't know where this assembly come from, but using gcc -O2, I'm
> getting the very same output for both functions for i386, x86_64,
> ppc and arm.

That was Linaro gcc 4.5 with -O3.

>> 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
>
> -- Jean-Daniel
>

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list