[FFmpeg-devel] [PATCH v6 4/4] lavf/utils: Normalize AVPacket.data to native endian
Mats Peterson
matsp888 at yahoo.com
Fri Mar 4 03:53:19 CET 2016
On 03/04/2016 03:51 AM, Mats Peterson wrote:
> On 03/04/2016 03:49 AM, Michael Niedermayer wrote:
>> On Fri, Mar 04, 2016 at 03:41:23AM +0100, Mats Peterson wrote:
>>> On 03/04/2016 03:30 AM, Michael Niedermayer wrote:
>>>>>
>>>>> - if (!*palette && ret == CONTAINS_PAL)
>>>>> - *palette = pkt->data + pkt->size - AVPALETTE_SIZE;
>>>>> + if (!*palette && ret == CONTAINS_PAL) {
>>>>> + uint8_t *pkt_pal = pkt->data + pkt->size - AVPALETTE_SIZE;
>>>>> + int i;
>>>>> + for (i = 0; i < AVPALETTE_COUNT; i++) {
>>>>> + uint8_t *p8 = pkt_pal + 4*i;
>>>>
>>>>> + uint32_t *p32 = (uint32_t *)p8;
>>>>
>>>> undefined behavior, violating alignment requirements, and possibly
>>>> aliassing violation
>>>>
>>>
>>> Really? It works just fine, so please elaborate.
>>
>> you cant cast arbitrary pointers to uint32_t
>>
>> uint32_t can have platform specific alignment requirements that are
>> stricter than what a random 4 uint8_t have.
>> pkt->size does not need to be a multiple of 4 so even if pkt->data
>> would be aligned enough p8 doesnt have to be
>>
>>
>
> Whatever. Forget this version 6 of the patch set and use version 5, with
> version 2 of patch 4/4 in it (the one I posted in PM as well). And I
> would be grateful if you could apply it soon. It's extensively tested here.
>
> Mats
>
I get what you mean with the alignment issues, though.
More information about the ffmpeg-devel
mailing list