avformat/avienc: Simplify writing padding

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2021-09-23 01:10:51 +02:00
parent c8e75076f1
commit 5eafbf0b08
1 changed files with 5 additions and 13 deletions

View File

@ -237,7 +237,6 @@ static void write_odml_master(AVFormatContext *s, int stream_index)
AVCodecParameters *par = st->codecpar; AVCodecParameters *par = st->codecpar;
AVIStream *avist = st->priv_data; AVIStream *avist = st->priv_data;
unsigned char tag[5]; unsigned char tag[5];
int j;
/* Starting to lay out AVI OpenDML master index. /* Starting to lay out AVI OpenDML master index.
* We want to make it JUNK entry for now, since we'd * We want to make it JUNK entry for now, since we'd
@ -250,10 +249,8 @@ static void write_odml_master(AVFormatContext *s, int stream_index)
avio_wl32(pb, 0); /* nEntriesInUse (will fill out later on) */ avio_wl32(pb, 0); /* nEntriesInUse (will fill out later on) */
ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, par->codec_type)); ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, par->codec_type));
/* dwChunkId */ /* dwChunkId */
avio_wl64(pb, 0); /* dwReserved[3] */ ffio_fill(pb, 0, 3 * 4 /* dwReserved[3] */
avio_wl32(pb, 0); /* Must be 0. */ + 16LL * avi->master_index_max_size);
for (j = 0; j < avi->master_index_max_size * 2; j++)
avio_wl64(pb, 0);
ff_end_tag(pb, avist->indexes.indx_start); ff_end_tag(pb, avist->indexes.indx_start);
} }
@ -351,10 +348,7 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, 0); avio_wl32(pb, 0);
avio_wl32(pb, 0); avio_wl32(pb, 0);
} }
avio_wl32(pb, 0); /* reserved */ ffio_fill(pb, 0, 4 * 4); /* reserved */
avio_wl32(pb, 0); /* reserved */
avio_wl32(pb, 0); /* reserved */
avio_wl32(pb, 0); /* reserved */
/* stream list */ /* stream list */
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -569,8 +563,7 @@ static int avi_write_header(AVFormatContext *s)
ffio_wfourcc(pb, "odml"); ffio_wfourcc(pb, "odml");
ffio_wfourcc(pb, "dmlh"); ffio_wfourcc(pb, "dmlh");
avio_wl32(pb, 248); avio_wl32(pb, 248);
for (i = 0; i < 248; i += 4) ffio_fill(pb, 0, 248);
avio_wl32(pb, 0);
ff_end_tag(pb, avi->odml_list); ff_end_tag(pb, avi->odml_list);
} }
@ -586,8 +579,7 @@ static int avi_write_header(AVFormatContext *s)
/* some padding for easier tag editing */ /* some padding for easier tag editing */
if (padding) { if (padding) {
list2 = ff_start_tag(pb, "JUNK"); list2 = ff_start_tag(pb, "JUNK");
for (i = padding; i > 0; i -= 4) ffio_fill(pb, 0, FFALIGN((uint32_t)padding, 4));
avio_wl32(pb, 0);
ff_end_tag(pb, list2); ff_end_tag(pb, list2);
} }