[Libav-user] Retrieve 10bit video frames

Michael Bradshaw mbradshaw at sorensonmedia.com
Fri May 18 18:59:22 CEST 2012


On Thu, May 17, 2012 at 5:43 AM, Dnegel X. <dnegel666 at gmail.com> wrote:
>> > However, the decoded frameYUV->data is of type uint8_t, and I would
>> > expect
>> > to get something able to store 10bit values like a uint16_t. So, what is
>> > returned in this 8bit array in this case? How can I proceed to get the
>> > 10bit
>> > values?
>>
>> Just cast the buffer.
>>
>> uint16_t* planes[3] = {(uint16_t*)frameYUV->data[0],
>> (uint16_t*)frameYUV->data[1], (uint16_t*)frameYUV->data[2]};
>>
>> --Michael
>
> Alright. I'm wondering if the part allocating space needs to be changed:
> numBytes = avpicture_get_size(out, width, height);
> buffer = (uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
>
> Is numBytes the number of uint8_t that can be cast to uint16_t, or
> should I allocate numBytes*sizeof(uint16_t)?

No, the allocation code does not need to change. If you look up the
docs for avpicture_get_size, you'll see that it calculates the
necessary size *in bytes*.


More information about the Libav-user mailing list