mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-23 11:19:55 +00:00
【修改说明】:pts帧号互转
Signed-off-by: Atrotro <wanganzhouhh@163.com>
This commit is contained in:
parent
6a5fcaf0f3
commit
2ebad80808
1
BUILD.gn
1
BUILD.gn
@ -145,6 +145,7 @@ config("ffmpeg_config") {
|
||||
"-DOHOS_NONSTANDARD_BOM",
|
||||
"-DOHOS_TIMED_META_TRACK",
|
||||
"-DOHOS_SUBTITLE_DEMUXER",
|
||||
"-DOHOS_EXPAND_MP4_INFO",
|
||||
]
|
||||
if (use_musl) {
|
||||
cflags += [ "-Wno-bool-operation" ]
|
||||
|
@ -940,6 +940,18 @@ const char *av_disposition_to_string(int disposition);
|
||||
#define AV_PTS_WRAP_ADD_OFFSET 1 ///< add the format specific offset on wrap detection
|
||||
#define AV_PTS_WRAP_SUB_OFFSET -1 ///< subtract the format specific offset on wrap detection
|
||||
|
||||
typedef struct AVCodecMOVStts {
|
||||
unsigned int count;
|
||||
unsigned int duration;
|
||||
struct AVCodecMOVStts *next;
|
||||
} AVCodecMOVStts;
|
||||
|
||||
typedef struct AVCodecMOVCtts {
|
||||
unsigned int count;
|
||||
int duration;
|
||||
struct AVCodecMOVCtts *next;
|
||||
} AVCodecMOVCtts;
|
||||
|
||||
/**
|
||||
* Stream structure.
|
||||
* New fields can be added to the end with minor version bumps.
|
||||
@ -1117,6 +1129,18 @@ typedef struct AVStream {
|
||||
*
|
||||
*/
|
||||
int pts_wrap_bits;
|
||||
|
||||
struct AVCodecMOVStts *stts_data_head;
|
||||
|
||||
struct AVCodecMOVCtts *ctts_data_head;
|
||||
|
||||
int time_scale;
|
||||
|
||||
/**
|
||||
* Headnodes derived from ffmpeg
|
||||
*
|
||||
* used to calculate pts and realize the function of pts&index convertng
|
||||
*/
|
||||
} AVStream;
|
||||
|
||||
struct AVCodecParserContext *av_stream_get_parser(const AVStream *s);
|
||||
|
@ -1542,6 +1542,10 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
if (ff_mov_lang_to_iso639(lang, language))
|
||||
av_dict_set(&st->metadata, "language", language, 0);
|
||||
avio_rb16(pb); /* quality */
|
||||
|
||||
#ifdef OHOS_EXPAND_MP4_INFO
|
||||
st->time_scale = sc->time_scale;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -3126,6 +3130,15 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
st = c->fc->streams[c->fc->nb_streams-1];
|
||||
sc = st->priv_data;
|
||||
|
||||
#ifdef OHOS_EXPAND_MP4_INFO
|
||||
st->stts_data_head = (struct AVCodecMOVStts *)malloc(sizeof(struct AVCodecMOVStts));
|
||||
st->stts_data_head->next = NULL;
|
||||
st->ctts_data_head = (struct AVCodecMOVCtts *)malloc(sizeof(struct AVCodecMOVCtts));
|
||||
st->ctts_data_head->next = NULL;
|
||||
struct AVCodecMOVStts *tail;
|
||||
tail = st->stts_data_head;
|
||||
#endif
|
||||
|
||||
avio_r8(pb); /* version */
|
||||
avio_rb24(pb); /* flags */
|
||||
entries = avio_rb32(pb);
|
||||
@ -3154,12 +3167,24 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
sc->stts_count = min_entries;
|
||||
sc->stts_data = stts_data;
|
||||
|
||||
#ifdef OHOS_EXPAND_MP4_INFO
|
||||
struct AVCodecMOVStts *tmp = (struct AVCodecMOVStts *)malloc(sizeof(struct AVCodecMOVStts));
|
||||
#endif
|
||||
|
||||
sample_count = avio_rb32(pb);
|
||||
sample_duration = avio_rb32(pb);
|
||||
|
||||
sc->stts_data[i].count= sample_count;
|
||||
sc->stts_data[i].duration= sample_duration;
|
||||
|
||||
#ifdef OHOS_EXPAND_MP4_INFO
|
||||
tmp->count = sample_count;
|
||||
tmp->duration = sample_duration;
|
||||
tail->next = tmp;
|
||||
tmp->next = NULL;
|
||||
tail = tmp;
|
||||
#endif
|
||||
|
||||
av_log(c->fc, AV_LOG_TRACE, "sample_count=%u, sample_duration=%u\n",
|
||||
sample_count, sample_duration);
|
||||
|
||||
@ -3267,6 +3292,11 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
st = c->fc->streams[c->fc->nb_streams-1];
|
||||
sc = st->priv_data;
|
||||
|
||||
#ifdef OHOS_EXPAND_MP4_INFO
|
||||
struct AVCodecMOVCtts *tail;
|
||||
tail = st->ctts_data_head;
|
||||
#endif
|
||||
|
||||
avio_r8(pb); /* version */
|
||||
avio_rb24(pb); /* flags */
|
||||
entries = avio_rb32(pb);
|
||||
@ -3283,6 +3313,10 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for (i = 0; i < entries && !pb->eof_reached; i++) {
|
||||
#ifdef OHOS_EXPAND_MP4_INFO
|
||||
struct AVCodecMOVCtts *tmp = (struct AVCodecMOVCtts *)malloc(sizeof(struct AVCodecMOVCtts));
|
||||
#endif
|
||||
|
||||
int count = avio_rb32(pb);
|
||||
int duration = avio_rb32(pb);
|
||||
|
||||
@ -3296,6 +3330,14 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
add_ctts_entry(&sc->ctts_data, &ctts_count, &sc->ctts_allocated_size,
|
||||
count, duration);
|
||||
|
||||
#ifdef OHOS_EXPAND_MP4_INFO
|
||||
tmp->count = count;
|
||||
tmp->duration = duration;
|
||||
tail->next = tmp;
|
||||
tmp->next = NULL;
|
||||
tail = tmp;
|
||||
#endif
|
||||
|
||||
av_log(c->fc, AV_LOG_TRACE, "count=%d, duration=%d\n",
|
||||
count, duration);
|
||||
|
||||
@ -8432,6 +8474,36 @@ static int mov_read_close(AVFormatContext *s)
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
AVStream *st = s->streams[i];
|
||||
MOVStreamContext *sc = st->priv_data;
|
||||
|
||||
#ifdef OHOS_EXPAND_MP4_INFO
|
||||
struct AVCodecMOVStts * cur_stts_node = st->stts_data_head;
|
||||
while (cur_stts_node != NULL && cur_stts_node->next != NULL) {
|
||||
struct AVCodecMOVStts * next = cur_stts_node->next;
|
||||
free(cur_stts_node);
|
||||
cur_stts_node = NULL;
|
||||
cur_stts_node = next;
|
||||
}
|
||||
if (cur_stts_node != NULL) {
|
||||
free(cur_stts_node);
|
||||
cur_stts_node = NULL;
|
||||
}
|
||||
struct AVCodecMOVCtts * cur_ctts_node = st->ctts_data_head;
|
||||
if (cur_ctts_node != NULL && cur_ctts_node->next == cur_ctts_node) {
|
||||
free(cur_ctts_node);
|
||||
cur_ctts_node = NULL;
|
||||
} else {
|
||||
while (cur_ctts_node!= NULL && cur_ctts_node->next != NULL) {
|
||||
struct AVCodecMOVStts * next = cur_ctts_node->next;
|
||||
free(cur_ctts_node);
|
||||
cur_ctts_node = NULL;
|
||||
cur_ctts_node = next;
|
||||
}
|
||||
if (cur_ctts_node != NULL) {
|
||||
free(cur_ctts_node);
|
||||
cur_ctts_node = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!sc)
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user