Message ID | 20211011112533.173814-1-zane@zanevaniperen.com |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel,1/2] avformat/argo_asf: pass name through as metadata | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
On 10/11/2021 8:25 AM, Zane van Iperen wrote: > Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> > --- > libavformat/argo_asf.c | 5 +++++ > libavformat/argo_asf.h | 3 ++- > tests/ref/acodec/adpcm-argo | 2 +- > 3 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c > index 7e759c7c0c..f729a393ad 100644 > --- a/libavformat/argo_asf.c > +++ b/libavformat/argo_asf.c > @@ -181,6 +181,7 @@ static int argo_asf_read_header(AVFormatContext *s) > AVStream *st; > ArgoASFDemuxContext *asf = s->priv_data; > uint8_t buf[ASF_MIN_BUFFER_SIZE]; > + char namebuf[ASF_MAX_NAME_SIZE + 1]; > > if (!(st = avformat_new_stream(s, NULL))) > return AVERROR(ENOMEM); > @@ -209,6 +210,10 @@ static int argo_asf_read_header(AVFormatContext *s) > > ff_argo_asf_parse_chunk_header(&asf->ckhdr, buf); > > + memcpy(namebuf, asf->fhdr.name, ASF_MAX_NAME_SIZE); > + namebuf[ASF_MAX_NAME_SIZE] = '\0'; av_strlcat() > + av_dict_set(&s->metadata, "title", namebuf, 0); > + > return ff_argo_asf_fill_stream(s, st, &asf->fhdr, &asf->ckhdr); > } > > diff --git a/libavformat/argo_asf.h b/libavformat/argo_asf.h > index e65125fb79..f0607c7859 100644 > --- a/libavformat/argo_asf.h > +++ b/libavformat/argo_asf.h > @@ -33,6 +33,7 @@ > #define ASF_CHUNK_HEADER_SIZE 20 > #define ASF_SAMPLE_COUNT 32 > #define ASF_MIN_BUFFER_SIZE FFMAX(ASF_FILE_HEADER_SIZE, ASF_CHUNK_HEADER_SIZE) > +#define ASF_MAX_NAME_SIZE 8 > > typedef struct ArgoASFFileHeader { > uint32_t magic; /*< Magic Number, {'A', 'S', 'F', '\0'} */ > @@ -40,7 +41,7 @@ typedef struct ArgoASFFileHeader { > uint16_t version_minor; /*< File Minor Version. */ > uint32_t num_chunks; /*< No. chunks in the file. */ > uint32_t chunk_offset; /*< Offset to the first chunk from the start of the file. */ > - int8_t name[8]; /*< Name. */ > + int8_t name[ASF_MAX_NAME_SIZE]; /*< Name. */ Why not make this ASF_MAX_NAME_SIZE + 1, and skip the stack buffer in argo_asf_read_header()? Also, ff_argo_asf_parse_file_header() could use a single AV_RL64 to read this instead of a loop reading one byte at a time. > } ArgoASFFileHeader; > > typedef struct ArgoASFChunkHeader { > diff --git a/tests/ref/acodec/adpcm-argo b/tests/ref/acodec/adpcm-argo > index 127153c081..4032a8f1fe 100644 > --- a/tests/ref/acodec/adpcm-argo > +++ b/tests/ref/acodec/adpcm-argo > @@ -1,4 +1,4 @@ > 14b2507d14e95c20bb7ae49b4fcbcbf1 *tests/data/fate/acodec-adpcm-argo.argo_asf > 281190 tests/data/fate/acodec-adpcm-argo.argo_asf > -cc5e5c695adeaebaa2b1f0df5ebd59ee *tests/data/fate/acodec-adpcm-argo.out.wav > +446f28460bdb7ff4361cf7d82ac22c3e *tests/data/fate/acodec-adpcm-argo.out.wav > stddev: 1542.05 PSNR: 32.57 MAXDIFF:59667 bytes: 1058400/ 1058432 >
diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c index 7e759c7c0c..f729a393ad 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -181,6 +181,7 @@ static int argo_asf_read_header(AVFormatContext *s) AVStream *st; ArgoASFDemuxContext *asf = s->priv_data; uint8_t buf[ASF_MIN_BUFFER_SIZE]; + char namebuf[ASF_MAX_NAME_SIZE + 1]; if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); @@ -209,6 +210,10 @@ static int argo_asf_read_header(AVFormatContext *s) ff_argo_asf_parse_chunk_header(&asf->ckhdr, buf); + memcpy(namebuf, asf->fhdr.name, ASF_MAX_NAME_SIZE); + namebuf[ASF_MAX_NAME_SIZE] = '\0'; + av_dict_set(&s->metadata, "title", namebuf, 0); + return ff_argo_asf_fill_stream(s, st, &asf->fhdr, &asf->ckhdr); } diff --git a/libavformat/argo_asf.h b/libavformat/argo_asf.h index e65125fb79..f0607c7859 100644 --- a/libavformat/argo_asf.h +++ b/libavformat/argo_asf.h @@ -33,6 +33,7 @@ #define ASF_CHUNK_HEADER_SIZE 20 #define ASF_SAMPLE_COUNT 32 #define ASF_MIN_BUFFER_SIZE FFMAX(ASF_FILE_HEADER_SIZE, ASF_CHUNK_HEADER_SIZE) +#define ASF_MAX_NAME_SIZE 8 typedef struct ArgoASFFileHeader { uint32_t magic; /*< Magic Number, {'A', 'S', 'F', '\0'} */ @@ -40,7 +41,7 @@ typedef struct ArgoASFFileHeader { uint16_t version_minor; /*< File Minor Version. */ uint32_t num_chunks; /*< No. chunks in the file. */ uint32_t chunk_offset; /*< Offset to the first chunk from the start of the file. */ - int8_t name[8]; /*< Name. */ + int8_t name[ASF_MAX_NAME_SIZE]; /*< Name. */ } ArgoASFFileHeader; typedef struct ArgoASFChunkHeader { diff --git a/tests/ref/acodec/adpcm-argo b/tests/ref/acodec/adpcm-argo index 127153c081..4032a8f1fe 100644 --- a/tests/ref/acodec/adpcm-argo +++ b/tests/ref/acodec/adpcm-argo @@ -1,4 +1,4 @@ 14b2507d14e95c20bb7ae49b4fcbcbf1 *tests/data/fate/acodec-adpcm-argo.argo_asf 281190 tests/data/fate/acodec-adpcm-argo.argo_asf -cc5e5c695adeaebaa2b1f0df5ebd59ee *tests/data/fate/acodec-adpcm-argo.out.wav +446f28460bdb7ff4361cf7d82ac22c3e *tests/data/fate/acodec-adpcm-argo.out.wav stddev: 1542.05 PSNR: 32.57 MAXDIFF:59667 bytes: 1058400/ 1058432
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> --- libavformat/argo_asf.c | 5 +++++ libavformat/argo_asf.h | 3 ++- tests/ref/acodec/adpcm-argo | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-)