Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquietvoid <tcchlisop0@gmail.com>2022-01-01 19:51:51 +0300
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-01-04 06:29:36 +0300
commit9906f9ae3b678d95b413dd4320e334ea3e2cf70a (patch)
tree6d7d2d48cbfd39ea2221389eefcaea2b98936d86 /libavformat/mov.c
parent05c07943b04de2514343b1de09dc6dca64502643 (diff)
avformat/mov: Refactor mov_read_dvcc_dvvc to use ff_isom_parse_dvcc_dvvc
To avoid duplicating code. The implementation in dovi_isom is identical. Signed-off-by: quietvoid <tcChlisop0@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c50
1 files changed, 7 insertions, 43 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 351ecde770..ad5ab6b491 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -55,6 +55,7 @@
#include "avformat.h"
#include "internal.h"
#include "avio_internal.h"
+#include "dovi_isom.h"
#include "riff.h"
#include "isom.h"
#include "libavcodec/get_bits.h"
@@ -7062,58 +7063,21 @@ static int mov_read_dmlp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
- uint32_t buf;
- AVDOVIDecoderConfigurationRecord *dovi;
- size_t dovi_size;
+ uint8_t buf[ISOM_DVCC_DVVC_SIZE];
int ret;
+ int64_t read_size = atom.size;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
- if ((uint64_t)atom.size > (1<<30) || atom.size < 4)
- return AVERROR_INVALIDDATA;
-
- dovi = av_dovi_alloc(&dovi_size);
- if (!dovi)
- return AVERROR(ENOMEM);
-
- dovi->dv_version_major = avio_r8(pb);
- dovi->dv_version_minor = avio_r8(pb);
-
- buf = avio_rb16(pb);
- dovi->dv_profile = (buf >> 9) & 0x7f; // 7 bits
- dovi->dv_level = (buf >> 3) & 0x3f; // 6 bits
- dovi->rpu_present_flag = (buf >> 2) & 0x01; // 1 bit
- dovi->el_present_flag = (buf >> 1) & 0x01; // 1 bit
- dovi->bl_present_flag = buf & 0x01; // 1 bit
- if (atom.size >= 24) { // 4 + 4 + 4 * 4
- buf = avio_r8(pb);
- dovi->dv_bl_signal_compatibility_id = (buf >> 4) & 0x0f; // 4 bits
- } else {
- // 0 stands for None
- // Dolby Vision V1.2.93 profiles and levels
- dovi->dv_bl_signal_compatibility_id = 0;
- }
+ // At most 24 bytes
+ read_size = FFMIN(read_size, ISOM_DVCC_DVVC_SIZE);
- ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF,
- (uint8_t *)dovi, dovi_size);
- if (ret < 0) {
- av_free(dovi);
+ if ((ret = ffio_read_size(pb, buf, read_size)) < 0)
return ret;
- }
- av_log(c, AV_LOG_TRACE, "DOVI in dvcC/dvvC/dvwC box, version: %d.%d, profile: %d, level: %d, "
- "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
- dovi->dv_version_major, dovi->dv_version_minor,
- dovi->dv_profile, dovi->dv_level,
- dovi->rpu_present_flag,
- dovi->el_present_flag,
- dovi->bl_present_flag,
- dovi->dv_bl_signal_compatibility_id
- );
-
- return 0;
+ return ff_isom_parse_dvcc_dvvc(c->fc, st, buf, read_size);
}
static int mov_read_kind(MOVContext *c, AVIOContext *pb, MOVAtom atom)