提交 baaf7b1b 编写于 作者: B Baptiste Coudurier

encode klv fill item length in fixed ber 4 bytes

Originally committed as revision 17199 to svn://svn.ffmpeg.org/ffmpeg/trunk
上级 ecc3a139
...@@ -289,6 +289,12 @@ static int klv_encode_ber_length(ByteIOContext *pb, uint64_t len) ...@@ -289,6 +289,12 @@ static int klv_encode_ber_length(ByteIOContext *pb, uint64_t len)
return 0; return 0;
} }
static void klv_encode_ber4_length(ByteIOContext *pb, int len)
{
put_byte(pb, 0x80 + 3);
put_be24(pb, len);
}
/* /*
* Get essence container ul index * Get essence container ul index
*/ */
...@@ -928,7 +934,7 @@ static int mxf_write_header_metadata_sets(AVFormatContext *s) ...@@ -928,7 +934,7 @@ static int mxf_write_header_metadata_sets(AVFormatContext *s)
static unsigned klv_fill_size(uint64_t size) static unsigned klv_fill_size(uint64_t size)
{ {
unsigned pad = KAG_SIZE - (size & (KAG_SIZE-1)); unsigned pad = KAG_SIZE - (size & (KAG_SIZE-1));
if (pad < 17) // smallest fill item possible if (pad < 20) // smallest fill item possible
return pad + KAG_SIZE; return pad + KAG_SIZE;
else else
return pad & (KAG_SIZE-1); return pad & (KAG_SIZE-1);
...@@ -1061,11 +1067,8 @@ static void mxf_write_klv_fill(AVFormatContext *s) ...@@ -1061,11 +1067,8 @@ static void mxf_write_klv_fill(AVFormatContext *s)
unsigned pad = klv_fill_size(url_ftell(s->pb)); unsigned pad = klv_fill_size(url_ftell(s->pb));
if (pad) { if (pad) {
put_buffer(s->pb, klv_fill_key, 16); put_buffer(s->pb, klv_fill_key, 16);
pad -= 16; pad -= 16 + 4;
pad -= klv_ber_length(pad); klv_encode_ber4_length(s->pb, pad);
klv_encode_ber_length(s->pb, pad);
for (; pad > 7; pad -= 8)
put_be64(s->pb, 0);
for (; pad; pad--) for (; pad; pad--)
put_byte(s->pb, 0); put_byte(s->pb, 0);
assert(!(url_ftell(s->pb) & (KAG_SIZE-1))); assert(!(url_ftell(s->pb) & (KAG_SIZE-1)));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册