unsigned drefs_count;
MOV_dref_t *drefs;
int dref_id;
+ int wrong_dts; ///< dts are wrong due to negative ctts
} MOVStreamContext;
typedef struct MOVContext {
* Compute codec id for 'lpcm' tag.
* See CoreAudioTypes and AudioStreamBasicDescription at Apple.
*/
-static int mov_get_lpcm_codec_id(int bps, int flags)
+static enum CodecID mov_get_lpcm_codec_id(int bps, int flags)
{
if (flags & 1) { // floating point
if (flags & 2) { // big endian
if (bps == 32) return CODEC_ID_PCM_F32BE;
- //else if (bps == 64) return CODEC_ID_PCM_F64BE;
+ else if (bps == 64) return CODEC_ID_PCM_F64BE;
} else {
- //if (bps == 32) return CODEC_ID_PCM_F32LE;
- //else if (bps == 64) return CODEC_ID_PCM_F64LE;
+ if (bps == 32) return CODEC_ID_PCM_F32LE;
+ else if (bps == 64) return CODEC_ID_PCM_F64LE;
}
} else {
if (flags & 2) {
else if (bps == 32) return CODEC_ID_PCM_S32LE;
}
}
- return 0;
+ return CODEC_ID_NONE;
}
static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
st->codec->codec_name[codec_name[0]] = 0;
}
- st->codec->bits_per_sample = get_be16(pb); /* depth */
+ st->codec->bits_per_coded_sample = get_be16(pb); /* depth */
st->codec->color_table_id = get_be16(pb); /* colortable id */
dprintf(c->fc, "depth %d, ctab id %d\n",
- st->codec->bits_per_sample, st->codec->color_table_id);
+ st->codec->bits_per_coded_sample, st->codec->color_table_id);
/* figure out the palette situation */
- color_depth = st->codec->bits_per_sample & 0x1F;
- color_greyscale = st->codec->bits_per_sample & 0x20;
+ color_depth = st->codec->bits_per_coded_sample & 0x1F;
+ color_greyscale = st->codec->bits_per_coded_sample & 0x20;
/* if the depth is 2, 4, or 8 bpp, file is palettized */
if ((color_depth == 2) || (color_depth == 4) ||
if (color_greyscale) {
int color_index, color_dec;
/* compute the greyscale palette */
- st->codec->bits_per_sample = color_depth;
+ st->codec->bits_per_coded_sample = color_depth;
color_count = 1 << color_depth;
color_index = 255;
color_dec = 256 / (color_count - 1);
st->codec->channels = get_be16(pb); /* channel count */
dprintf(c->fc, "audio channels %d\n", st->codec->channels);
- st->codec->bits_per_sample = get_be16(pb); /* sample size */
+ st->codec->bits_per_coded_sample = get_be16(pb); /* sample size */
sc->audio_cid = get_be16(pb);
get_be16(pb); /* packet size = 0 */
st->codec->sample_rate = av_int2dbl(get_be64(pb)); /* float 64 */
st->codec->channels = get_be32(pb);
get_be32(pb); /* always 0x7F000000 */
- st->codec->bits_per_sample = get_be32(pb); /* bits per channel if sound is uncompressed */
+ st->codec->bits_per_coded_sample = get_be32(pb); /* bits per channel if sound is uncompressed */
flags = get_be32(pb); /* lcpm format specific flag */
sc->bytes_per_frame = get_be32(pb); /* bytes per audio packet if constant */
sc->samples_per_frame = get_be32(pb); /* lpcm frames per audio packet if constant */
if (format == MKTAG('l','p','c','m'))
- st->codec->codec_id = mov_get_lpcm_codec_id(st->codec->bits_per_sample, flags);
+ st->codec->codec_id = mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, flags);
}
}
switch (st->codec->codec_id) {
case CODEC_ID_PCM_S8:
case CODEC_ID_PCM_U8:
- if (st->codec->bits_per_sample == 16)
+ if (st->codec->bits_per_coded_sample == 16)
st->codec->codec_id = CODEC_ID_PCM_S16BE;
break;
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
- if (st->codec->bits_per_sample == 8)
+ if (st->codec->bits_per_coded_sample == 8)
st->codec->codec_id = CODEC_ID_PCM_S8;
- else if (st->codec->bits_per_sample == 24)
+ else if (st->codec->bits_per_coded_sample == 24)
st->codec->codec_id =
st->codec->codec_id == CODEC_ID_PCM_S16BE ?
CODEC_ID_PCM_S24BE : CODEC_ID_PCM_S24LE;
bits_per_sample = av_get_bits_per_sample(st->codec->codec_id);
if (bits_per_sample) {
- st->codec->bits_per_sample = bits_per_sample;
+ st->codec->bits_per_coded_sample = bits_per_sample;
sc->sample_size = (bits_per_sample >> 3) * st->codec->channels;
}
} else if(st->codec->codec_type==CODEC_TYPE_SUBTITLE){
break;
#endif
/* no ifdef since parameters are always those */
- case CODEC_ID_AMR_WB:
- st->codec->sample_rate= 16000;
- st->codec->channels= 1; /* really needed */
- break;
case CODEC_ID_QCELP:
case CODEC_ID_AMR_NB:
+ case CODEC_ID_AMR_WB:
st->codec->frame_size= sc->samples_per_frame;
- st->codec->sample_rate= 8000;
st->codec->channels= 1; /* really needed */
break;
case CODEC_ID_MP2:
int duration =get_be32(pb);
if (duration < 0) {
- av_log(c->fc, AV_LOG_WARNING, "negative ctts, ignoring\n");
- sc->ctts_count = 0;
- url_fskip(pb, 8 * (entries - i - 1));
- break;
+ sc->wrong_dts = 1;
+ st->codec->has_b_frames = 1;
}
sc->ctts_data[i].count = count;
sc->ctts_data[i].duration= duration;
- sc->time_rate= ff_gcd(sc->time_rate, duration);
+ sc->time_rate= ff_gcd(sc->time_rate, FFABS(duration));
}
return 0;
}
st->codec->width= 0; /* let decoder init width/height */
st->codec->height= 0;
break;
-#ifdef CONFIG_VORBIS_DECODER
- case CODEC_ID_VORBIS:
-#endif
- st->codec->sample_rate= 0; /* let decoder init parameters properly */
- break;
}
/* Do not need those anymore. */
uint32_t tag = get_le32(pb);
uint64_t next = url_ftell(pb) + tag_size - 8;
- if (next > end) // stop if tag_size is wrong
+ if (tag_size < 8 || next > end) // stop if tag_size is wrong
break;
switch (tag) {
((int64_t) display_matrix[2][i] << 16);
//sample aspect ratio is new width/height divided by old width/height
- st->codec->sample_aspect_ratio = av_d2q(
+ st->sample_aspect_ratio = av_d2q(
((double) disp_transform[0] * height) /
((double) disp_transform[1] * width), INT_MAX);
}
sc->sample_to_ctime_index++;
sc->sample_to_ctime_sample = 0;
}
+ if (sc->wrong_dts)
+ pkt->dts = AV_NOPTS_VALUE;
} else {
AVStream *st = s->streams[sc->ffindex];
int64_t next_dts = (sc->current_sample < sc->sample_count) ?