#include "qtpalette.h"
-
-#undef NDEBUG
-#include <assert.h>
-
/* those functions parse an atom */
/* links atom IDs to parse functions */
typedef struct MOVParseTableEntry {
AVStream *st;
uint32_t type;
uint32_t av_unused ctype;
- int title_size;
+ int64_t title_size;
char *title_str;
if (c->fc->nb_streams < 1) // meta before first trak
return AVERROR(ENOMEM);
avio_read(pb, title_str, title_size);
title_str[title_size] = 0;
- if (title_str[0])
- av_dict_set(&st->metadata, "handler_name", title_str +
- (!c->isom && title_str[0] == title_size - 1), 0);
+ if (title_str[0]) {
+ int off = (!c->isom && title_str[0] == title_size - 1);
+ av_dict_set(&st->metadata, "handler_name", title_str + off, 0);
+ }
av_freep(&title_str);
}
static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
+ enum AVAudioServiceType *ast;
int ac3info, acmod, lfeon, bsmod;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
+ ast = (enum AVAudioServiceType*)ff_stream_new_side_data(st, AV_PKT_DATA_AUDIO_SERVICE_TYPE,
+ sizeof(*ast));
+ if (!ast)
+ return AVERROR(ENOMEM);
+
ac3info = avio_rb24(pb);
bsmod = (ac3info >> 14) & 0x7;
acmod = (ac3info >> 11) & 0x7;
st->codec->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
if (lfeon)
st->codec->channel_layout |= AV_CH_LOW_FREQUENCY;
- st->codec->audio_service_type = bsmod;
+ *ast = bsmod;
if (st->codec->channels > 1 && bsmod == 0x7)
- st->codec->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
+ *ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;
+
+ st->codec->audio_service_type = *ast;
return 0;
}
static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
+ enum AVAudioServiceType *ast;
int eac3info, acmod, lfeon, bsmod;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
+ ast = (enum AVAudioServiceType*)ff_stream_new_side_data(st, AV_PKT_DATA_AUDIO_SERVICE_TYPE,
+ sizeof(*ast));
+ if (!ast)
+ return AVERROR(ENOMEM);
+
/* No need to parse fields for additional independent substreams and its
* associated dependent substreams since libavcodec's E-AC-3 decoder
* does not support them yet. */
if (lfeon)
st->codec->channel_layout |= AV_CH_LOW_FREQUENCY;
st->codec->channels = av_get_channel_layout_nb_channels(st->codec->channel_layout);
- st->codec->audio_service_type = bsmod;
+ *ast = bsmod;
if (st->codec->channels > 1 && bsmod == 0x7)
- st->codec->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
+ *ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;
+
+ st->codec->audio_service_type = *ast;
return 0;
}
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
num, den);
} else if (den != 0) {
- st->sample_aspect_ratio.num = num;
- st->sample_aspect_ratio.den = den;
+ av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den,
+ num, den, 32767);
}
return 0;
}
}
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- if (!st->sample_aspect_ratio.num &&
+ if (!st->sample_aspect_ratio.num && st->codec->width && st->codec->height &&
+ sc->height && sc->width &&
(st->codec->width != sc->width || st->codec->height != sc->height)) {
st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) /
((double)st->codec->width * sc->height), INT_MAX);