summaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-07-10 04:28:50 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-07-10 04:28:50 +0200
commit2f56a97f2488146f209de415e3338f7e597c5719 (patch)
treedc5738f578f616d5af685391e82220452b3fbb3e /libavformat
parenta7d3a51dd1efa3073cc9d419a73f709f784ce267 (diff)
parent7f7dc4fb55904e7b51b78ebca746c6755fc9770c (diff)
downloadffmpeg-streaming-2f56a97f2488146f209de415e3338f7e597c5719.zip
ffmpeg-streaming-2f56a97f2488146f209de415e3338f7e597c5719.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits) H.264: fix filter_mb_fast with 4:4:4 + 8x8dct alsa: limit buffer_size to 32768 frames. alsa: fallback to buffer_size/4 for period_size. doc: replace @pxref by @ref where appropriate mpeg1video: don't abort if thread_count is too high. segafilm: add support for videos with cri adx adpcm gxf: Fix 25 fps DV material in GXF being misdetected as 50 fps libxvid: Add const qualifier to silence compiler warning. H.264: improve qp_thresh check H.264: use fill_rectangle in CABAC decoding H.264: Remove redundant hl_motion_16/8 code H.264: merge fill_rectangle into P-SKIP MV prediction, to match B-SKIP H.264: faster P-SKIP decoding H.264: av_always_inline some more functions H.264: Add x86 assembly for 10-bit H.264 predict functions swscale: rename uv_off/uv_off2 to uv_off_px/byte. swscale: implement error dithering in planarCopyWrapper. swscale: error dithering for 16/9/10-bit to 8-bit. swscale: fix overflow in 16-bit vertical scaling. swscale: fix crash in 8-bpc bilinear output without alpha. ... Conflicts: doc/developer.texi libavdevice/alsa-audio.h libavformat/gxf.c libswscale/swscale.c libswscale/swscale_internal.h libswscale/swscale_unscaled.c libswscale/x86/swscale_template.c tests/ref/lavfi/pixdesc tests/ref/lavfi/pixfmts_copy tests/ref/lavfi/pixfmts_crop tests/ref/lavfi/pixfmts_hflip tests/ref/lavfi/pixfmts_null tests/ref/lavfi/pixfmts_scale tests/ref/lavfi/pixfmts_vflip Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/gxf.c27
-rw-r--r--libavformat/segafilm.c28
2 files changed, 38 insertions, 17 deletions
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index 7002a1d..1d83cc3 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -264,7 +264,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
int map_len;
int len;
AVRational main_timebase = {0, 0};
- struct gxf_stream_info si;
+ struct gxf_stream_info *si = s->priv_data;
int i;
if (!parse_packet_header(pb, &pkt_type, &map_len) || pkt_type != PKT_MAP) {
av_log(s, AV_LOG_ERROR, "map packet not found\n");
@@ -282,7 +282,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
return 0;
}
map_len -= len;
- gxf_material_tags(pb, &len, &si);
+ gxf_material_tags(pb, &len, si);
avio_skip(pb, len);
map_len -= 2;
len = avio_rb16(pb); // length of track description
@@ -300,7 +300,7 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
track_id = avio_r8(pb);
track_len = avio_rb16(pb);
len -= track_len;
- gxf_track_tags(pb, &track_len, &si);
+ gxf_track_tags(pb, &track_len, si);
avio_skip(pb, track_len);
if (!(track_type & 0x80)) {
av_log(s, AV_LOG_ERROR, "invalid track type %x\n", track_type);
@@ -316,12 +316,12 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
if (idx < 0) continue;
st = s->streams[idx];
if (!main_timebase.num || !main_timebase.den) {
- main_timebase.num = si.frames_per_second.den;
- main_timebase.den = si.frames_per_second.num * 2;
+ main_timebase.num = si->frames_per_second.den;
+ main_timebase.den = si->frames_per_second.num * 2;
}
- st->start_time = si.first_field;
- if (si.first_field != AV_NOPTS_VALUE && si.last_field != AV_NOPTS_VALUE)
- st->duration = si.last_field - si.first_field;
+ st->start_time = si->first_field;
+ if (si->first_field != AV_NOPTS_VALUE && si->last_field != AV_NOPTS_VALUE)
+ st->duration = si->last_field - si->first_field;
}
if (len < 0)
av_log(s, AV_LOG_ERROR, "invalid track description length specified\n");
@@ -422,7 +422,9 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
AVIOContext *pb = s->pb;
GXFPktType pkt_type;
int pkt_len;
- while (!url_feof(pb)) {
+ struct gxf_stream_info *si = s->priv_data;
+
+ while (!pb->eof_reached) {
AVStream *st;
int track_type, track_id, ret;
int field_nr, field_info, skip = 0;
@@ -473,6 +475,11 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
avio_skip(pb, skip);
pkt->stream_index = stream_index;
pkt->dts = field_nr;
+
+ //set duration manually for DV or else lavf misdetects the frame rate
+ if (st->codec->codec_id == CODEC_ID_DVVIDEO)
+ pkt->duration = si->fields_per_frame;
+
return ret;
}
return AVERROR(EIO);
@@ -518,7 +525,7 @@ static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index,
AVInputFormat ff_gxf_demuxer = {
"gxf",
NULL_IF_CONFIG_SMALL("GXF format"),
- 0,
+ sizeof(struct gxf_stream_info),
gxf_probe,
gxf_header,
gxf_packet,
diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
index ae194d4..2251a89 100644
--- a/libavformat/segafilm.c
+++ b/libavformat/segafilm.c
@@ -111,7 +111,9 @@ static int film_read_header(AVFormatContext *s,
film->audio_samplerate = AV_RB16(&scratch[24]);
film->audio_channels = scratch[21];
film->audio_bits = scratch[22];
- if (film->audio_bits == 8)
+ if (scratch[23] == 2)
+ film->audio_type = CODEC_ID_ADPCM_ADX;
+ else if (film->audio_bits == 8)
film->audio_type = CODEC_ID_PCM_S8;
else if (film->audio_bits == 16)
film->audio_type = CODEC_ID_PCM_S16BE;
@@ -149,12 +151,19 @@ static int film_read_header(AVFormatContext *s,
st->codec->codec_id = film->audio_type;
st->codec->codec_tag = 1;
st->codec->channels = film->audio_channels;
- st->codec->bits_per_coded_sample = film->audio_bits;
st->codec->sample_rate = film->audio_samplerate;
+
+ if (film->audio_type == CODEC_ID_ADPCM_ADX) {
+ st->codec->bits_per_coded_sample = 18 * 8 / 32;
+ st->codec->block_align = st->codec->channels * 18;
+ } else {
+ st->codec->bits_per_coded_sample = film->audio_bits;
+ st->codec->block_align = st->codec->channels *
+ st->codec->bits_per_coded_sample / 8;
+ }
+
st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec->bits_per_coded_sample;
- st->codec->block_align = st->codec->channels *
- st->codec->bits_per_coded_sample / 8;
}
/* load the sample table */
@@ -187,8 +196,12 @@ static int film_read_header(AVFormatContext *s,
film->sample_table[i].pts *= film->base_clock;
film->sample_table[i].pts /= film->audio_samplerate;
- audio_frame_counter += (film->sample_table[i].sample_size /
- (film->audio_channels * film->audio_bits / 8));
+ if (film->audio_type == CODEC_ID_ADPCM_ADX)
+ audio_frame_counter += (film->sample_table[i].sample_size * 32 /
+ (18 * film->audio_channels));
+ else
+ audio_frame_counter += (film->sample_table[i].sample_size /
+ (film->audio_channels * film->audio_bits / 8));
} else {
film->sample_table[i].stream = film->video_stream_index;
film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
@@ -227,7 +240,8 @@ static int film_read_packet(AVFormatContext *s,
return AVERROR(ENOMEM);
avio_read(pb, pkt->data, sample->sample_size);
} else if ((sample->stream == film->audio_stream_index) &&
- (film->audio_channels == 2)) {
+ (film->audio_channels == 2) &&
+ (film->audio_type != CODEC_ID_ADPCM_ADX)) {
/* stereo PCM needs to be interleaved */
if (av_new_packet(pkt, sample->sample_size))
OpenPOWER on IntegriCloud