On 31/08/15 11:23, Hendrik Leppkes wrote:
> On Mon, Aug 31, 2015 at 11:22 AM, Luca Barbato <[email protected]> wrote:
>> On 30/08/15 16:46, Vittorio Giovara wrote:
>>> From: Michael Niedermayer <[email protected]>
>>>
>>> Despite '417792' being reported in the binary decoder, the buffer at
>>> encoding time needs to be bigger to avoid running out of space due to
>>> interlace handling.
>>>
>>> Signed-off-by: Vittorio Giovara <[email protected]>
>>> ---
>>>  libavcodec/dnxhddata.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
>>> index 85e3829..9d2e4e8 100644
>>> --- a/libavcodec/dnxhddata.c
>>> +++ b/libavcodec/dnxhddata.c
>>> @@ -1103,7 +1103,7 @@ const CIDEntry ff_dnxhd_cid_table[] = {
>>>        dnxhd_1237_ac_flags,
>>>        dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run,
>>>        { 63, 84, 100, 110 } },
>>> -    { 1260, 1440, 1080, 1, 417792, 417792, 4, 8, 3,
>>> +    { 1260, 1440, 1080, 1, 835584, 417792, 4, 8, 3,
>>>        dnxhd_1260_luma_weight, dnxhd_1260_chroma_weight,
>>>        dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
>>>        dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level,
>>>
>>
>> Is it needed only there or for each cid when interlaced is set?
>>
>> Something like
>>
>> diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
>> index 228ee46..d6d08f0 100644
>> --- a/libavcodec/dnxhdenc.c
>> +++ b/libavcodec/dnxhdenc.c
>> @@ -1043,10 +1043,14 @@ static int dnxhd_encode_picture(AVCodecContext
>> *avctx, AVPacket *pkt,
>>  {
>>      DNXHDEncContext *ctx = avctx->priv_data;
>>      int first_field = 1;
>> +    int frame_size = ctx->cid_table->frame_size;
>>      int offset, i, ret;
>>      uint8_t *buf, *sd;
>>
>> -    if ((ret = ff_alloc_packet(pkt, ctx->cid_table->frame_size)) < 0) {
>> +    if (ctx->interlaced)
>> +        frame_size *= 2;
>> +
>> +    if ((ret = ff_alloc_packet(pkt, frame_size)) < 0) {
>>          av_log(avctx, AV_LOG_ERROR,
>>                 "output buffer is too small to compress picture\n");
>>          return ret;
>>
>>
>> Seems slightly future-proof.
>>
> 
> Its also future-proof to just set the proper frame sizes in the
> tables, since you need to specify one anyway, it might as well be
> correct, and not doubled in the encoder later.

It is not since then the next time somebody pokes around the binary and
reports back you would have the same problem again.

Doubling the size is just needed for interlace apparently.

lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to