summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ffmpeg.c2
-rw-r--r--libavcodec/atrac3.c2
-rw-r--r--libavcodec/bethsoftvideo.c14
-rw-r--r--libavcodec/proresenc_kostya.c2
-rw-r--r--libavcodec/shorten.c3
-rw-r--r--libavcodec/vc1dec.c11
-rw-r--r--libavcodec/ws-snd1.c4
-rw-r--r--libavcodec/x86/mpegaudiodec_mmx.c21
-rw-r--r--libavformat/bethsoftvid.c162
-rw-r--r--libavformat/movenc.c7
-rw-r--r--libavformat/movenchint.c2
-rw-r--r--libavformat/rtp.h2
-rw-r--r--libavformat/rtpdec.c2
-rw-r--r--libavformat/rtpproto.c2
-rw-r--r--libavformat/rtsp.c3
-rw-r--r--libavformat/rtspenc.c2
-rw-r--r--tests/ref/fate/bethsoft-vid143
17 files changed, 244 insertions, 140 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 8659ff712d..dfe739463f 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -502,7 +502,7 @@ static int alloc_buffer(AVCodecContext *s, InputStream *ist, FrameBuffer **pbuf)
/* XXX this shouldn't be needed, but some tests break without this line
* those decoders are buggy and need to be fixed.
* the following tests fail:
- * bethsoft-vid, cdgraphics, ansi, aasc, fraps-v1, qtrle-1bit
+ * cdgraphics, ansi, aasc, fraps-v1, qtrle-1bit
*/
memset(buf->base[0], 128, ret);
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index e72df12d62..b297789747 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -402,7 +402,7 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
for (k=0; k<coded_components; k++) {
sfIndx = get_bits(gb,6);
- if(component_count>=64)
+ if (component_count >= 64)
return AVERROR_INVALIDDATA;
pComponent[component_count].pos = j * 64 + (get_bits(gb,6));
max_coded_values = SAMPLES_PER_FRAME - pComponent[component_count].pos;
diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c
index d85783b109..538e42614a 100644
--- a/libavcodec/bethsoftvideo.c
+++ b/libavcodec/bethsoftvideo.c
@@ -73,14 +73,23 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
uint8_t * dst;
uint8_t * frame_end;
int remaining = avctx->width; // number of bytes remaining on a line
- const int wrap_to_next_line = vid->frame.linesize[0] - avctx->width;
- int code;
+ int wrap_to_next_line;
+ int code, ret;
int yoffset;
if (avctx->reget_buffer(avctx, &vid->frame)) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
}
+ wrap_to_next_line = vid->frame.linesize[0] - avctx->width;
+
+ if (avpkt->side_data_elems > 0 &&
+ avpkt->side_data[0].type == AV_PKT_DATA_PALETTE) {
+ bytestream2_init(&vid->g, avpkt->side_data[0].data,
+ avpkt->side_data[0].size);
+ if ((ret = set_palette(vid)) < 0)
+ return ret;
+ }
bytestream2_init(&vid->g, avpkt->data, avpkt->size);
dst = vid->frame.data[0];
@@ -88,7 +97,6 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
switch(block_type = bytestream2_get_byte(&vid->g)){
case PALETTE_BLOCK: {
- int ret;
*data_size = 0;
if ((ret = set_palette(vid)) < 0) {
av_log(avctx, AV_LOG_ERROR, "error reading palette\n");
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 293735515b..242537b001 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -265,6 +265,7 @@ static void encode_dcs(PutBitContext *pb, DCTELEM *blocks,
prev_dc = (blocks[0] - 0x4000) / scale;
encode_vlc_codeword(pb, FIRST_DC_CB, MAKE_CODE(prev_dc));
+ sign = 0;
codebook = 3;
blocks += 64;
@@ -409,6 +410,7 @@ static int estimate_dcs(int *error, DCTELEM *blocks, int blocks_per_slice,
prev_dc = (blocks[0] - 0x4000) / scale;
bits = estimate_vlc(FIRST_DC_CB, MAKE_CODE(prev_dc));
+ sign = 0;
codebook = 3;
blocks += 64;
*error += FFABS(blocks[0] - 0x4000) % scale;
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index ef58aaa6aa..fc3a35e82a 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -141,7 +141,8 @@ static int allocate_buffers(ShortenContext *s)
return AVERROR(ENOMEM);
s->offset[chan] = tmp_ptr;
- tmp_ptr = av_realloc(s->decoded_base[chan], sizeof(int32_t)*(s->blocksize + s->nwrap));
+ tmp_ptr = av_realloc(s->decoded_base[chan], (s->blocksize + s->nwrap) *
+ sizeof(s->decoded_base[0][0]));
if (!tmp_ptr)
return AVERROR(ENOMEM);
s->decoded_base[chan] = tmp_ptr;
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 05809d36b0..a10ec85f02 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -478,7 +478,10 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
int off, off_uv;
int v_edge_pos = s->v_edge_pos >> v->field_mode;
- if (!v->field_mode && !v->s.last_picture.f.data[0])
+
+ if ((!v->field_mode ||
+ (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
+ !v->s.last_picture.f.data[0])
return;
mx = s->mv[dir][0][0];
@@ -690,7 +693,9 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir)
int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0;
int v_edge_pos = s->v_edge_pos >> v->field_mode;
- if (!v->field_mode && !v->s.last_picture.f.data[0])
+ if ((!v->field_mode ||
+ (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
+ !v->s.last_picture.f.data[0])
return;
mx = s->mv[dir][n][0];
@@ -946,6 +951,8 @@ static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
if (dominant)
chroma_ref_type = !v->cur_field_type;
}
+ if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f.data[0])
+ return;
s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
uvmx = (tx + ((tx & 3) == 3)) >> 1;
diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c
index 2cb8bb44a6..8df19a8bc9 100644
--- a/libavcodec/ws-snd1.c
+++ b/libavcodec/ws-snd1.c
@@ -112,8 +112,8 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, void *data,
/* make sure we don't write past the output buffer */
switch (code) {
- case 0: smp = 4*(count+1); break;
- case 1: smp = 2*(count+1); break;
+ case 0: smp = 4 * (count + 1); break;
+ case 1: smp = 2 * (count + 1); break;
case 2: smp = (count & 0x20) ? 1 : count + 1; break;
default: smp = count + 1; break;
}
diff --git a/libavcodec/x86/mpegaudiodec_mmx.c b/libavcodec/x86/mpegaudiodec_mmx.c
index b85b8a5548..939b441277 100644
--- a/libavcodec/x86/mpegaudiodec_mmx.c
+++ b/libavcodec/x86/mpegaudiodec_mmx.c
@@ -106,7 +106,26 @@ static void apply_window_mp3(float *in, float *win, int *unused, float *out,
float sum;
/* copy to avoid wrap */
- memcpy(in + 512, in, 32 * sizeof(*in));
+ __asm__ volatile(
+ "movaps 0(%0), %%xmm0 \n\t" \
+ "movaps 16(%0), %%xmm1 \n\t" \
+ "movaps 32(%0), %%xmm2 \n\t" \
+ "movaps 48(%0), %%xmm3 \n\t" \
+ "movaps %%xmm0, 0(%1) \n\t" \
+ "movaps %%xmm1, 16(%1) \n\t" \
+ "movaps %%xmm2, 32(%1) \n\t" \
+ "movaps %%xmm3, 48(%1) \n\t" \
+ "movaps 64(%0), %%xmm0 \n\t" \
+ "movaps 80(%0), %%xmm1 \n\t" \
+ "movaps 96(%0), %%xmm2 \n\t" \
+ "movaps 112(%0), %%xmm3 \n\t" \
+ "movaps %%xmm0, 64(%1) \n\t" \
+ "movaps %%xmm1, 80(%1) \n\t" \
+ "movaps %%xmm2, 96(%1) \n\t" \
+ "movaps %%xmm3, 112(%1) \n\t"
+ ::"r"(in), "r"(in+512)
+ :"memory"
+ );
apply_window(in + 16, win , win + 512, suma, sumc, 16);
apply_window(in + 32, win + 48, win + 640, sumb, sumd, 16);
diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c
index e1786c9351..a98b1bda2c 100644
--- a/libavformat/bethsoftvid.c
+++ b/libavformat/bethsoftvid.c
@@ -32,17 +32,23 @@
#include "internal.h"
#include "libavcodec/bethsoftvideo.h"
+#define BVID_PALETTE_SIZE 3 * 256
+
+#define DEFAULT_SAMPLE_RATE 11111
+
typedef struct BVID_DemuxContext
{
int nframes;
+ int sample_rate; /**< audio sample rate */
+ int width; /**< video width */
+ int height; /**< video height */
/** delay value between frames, added to individual frame delay.
* custom units, which will be added to other custom units (~=16ms according
* to free, unofficial documentation) */
int bethsoft_global_delay;
-
- /** video presentation time stamp.
- * delay = 16 milliseconds * (global_delay + per_frame_delay) */
- int video_pts;
+ int video_index; /**< video stream index */
+ int audio_index; /**< audio stream index */
+ uint8_t *palette;
int is_finished;
@@ -61,7 +67,6 @@ static int vid_read_header(AVFormatContext *s)
{
BVID_DemuxContext *vid = s->priv_data;
AVIOContext *pb = s->pb;
- AVStream *stream;
/* load main header. Contents:
* bytes: 'V' 'I' 'D'
@@ -69,43 +74,50 @@ static int vid_read_header(AVFormatContext *s)
*/
avio_skip(pb, 5);
vid->nframes = avio_rl16(pb);
-
- stream = avformat_new_stream(s, NULL);
- if (!stream)
- return AVERROR(ENOMEM);
- avpriv_set_pts_info(stream, 32, 1, 60); // 16 ms increments, i.e. 60 fps
- stream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- stream->codec->codec_id = CODEC_ID_BETHSOFTVID;
- stream->codec->width = avio_rl16(pb);
- stream->codec->height = avio_rl16(pb);
- stream->codec->pix_fmt = PIX_FMT_PAL8;
+ vid->width = avio_rl16(pb);
+ vid->height = avio_rl16(pb);
vid->bethsoft_global_delay = avio_rl16(pb);
avio_rl16(pb);
- // done with video codec, set up audio codec
- stream = avformat_new_stream(s, NULL);
- if (!stream)
- return AVERROR(ENOMEM);
- stream->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- stream->codec->codec_id = CODEC_ID_PCM_U8;
- stream->codec->channels = 1;
- stream->codec->sample_rate = 11025;
- stream->codec->bits_per_coded_sample = 8;
- stream->codec->bit_rate = stream->codec->channels * stream->codec->sample_rate * stream->codec->bits_per_coded_sample;
+ // wait until the first packet to create each stream
+ vid->video_index = -1;
+ vid->audio_index = -1;
+ vid->sample_rate = DEFAULT_SAMPLE_RATE;
+ s->ctx_flags |= AVFMTCTX_NOHEADER;
return 0;
}
#define BUFFER_PADDING_SIZE 1000
static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
- uint8_t block_type, AVFormatContext *s, int npixels)
+ uint8_t block_type, AVFormatContext *s)
{
uint8_t * vidbuf_start = NULL;
int vidbuf_nbytes = 0;
int code;
int bytes_copied = 0;
- int position;
+ int position, duration, npixels;
unsigned int vidbuf_capacity;
+ int ret = 0;
+ AVStream *st;
+
+ if (vid->video_index < 0) {
+ st = avformat_new_stream(s, NULL);
+ if (!st)
+ return AVERROR(ENOMEM);
+ vid->video_index = st->index;
+ if (vid->audio_index < 0) {
+ av_log_ask_for_sample(s, "No audio packet before first video "
+ "packet. Using default video time base.\n");
+ }
+ avpriv_set_pts_info(st, 64, 185, vid->sample_rate);
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codec->codec_id = CODEC_ID_BETHSOFTVID;
+ st->codec->width = vid->width;
+ st->codec->height = vid->height;
+ }
+ st = s->streams[vid->video_index];
+ npixels = st->codec->width * st->codec->height;
vidbuf_start = av_malloc(vidbuf_capacity = BUFFER_PADDING_SIZE);
if(!vidbuf_start)
@@ -116,13 +128,15 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
vidbuf_start[vidbuf_nbytes++] = block_type;
- // get the video delay (next int16), and set the presentation time
- vid->video_pts += vid->bethsoft_global_delay + avio_rl16(pb);
+ // get the current packet duration
+ duration = vid->bethsoft_global_delay + avio_rl16(pb);
// set the y offset if it exists (decoder header data should be in data section)
if(block_type == VIDEO_YOFF_P_FRAME){
- if(avio_read(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2)
+ if (avio_read(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2) {
+ ret = AVERROR(EIO);
goto fail;
+ }
vidbuf_nbytes += 2;
}
@@ -138,8 +152,10 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
if(block_type == VIDEO_I_FRAME)
vidbuf_start[vidbuf_nbytes++] = avio_r8(pb);
} else if(code){ // plain sequence
- if(avio_read(pb, &vidbuf_start[vidbuf_nbytes], code) != code)
+ if (avio_read(pb, &vidbuf_start[vidbuf_nbytes], code) != code) {
+ ret = AVERROR(EIO);
goto fail;
+ }
vidbuf_nbytes += code;
}
bytes_copied += code & 0x7F;
@@ -149,25 +165,37 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
avio_seek(pb, -1, SEEK_CUR);
break;
}
- if(bytes_copied > npixels)
+ if (bytes_copied > npixels) {
+ ret = AVERROR_INVALIDDATA;
goto fail;
+ }
} while(code);
// copy data into packet
- if(av_new_packet(pkt, vidbuf_nbytes) < 0)
+ if ((ret = av_new_packet(pkt, vidbuf_nbytes)) < 0)
goto fail;
memcpy(pkt->data, vidbuf_start, vidbuf_nbytes);
av_free(vidbuf_start);
pkt->pos = position;
- pkt->stream_index = 0; // use the video decoder, which was initialized as the first stream
- pkt->pts = vid->video_pts;
+ pkt->stream_index = vid->video_index;
+ pkt->duration = duration;
+ if (block_type == VIDEO_I_FRAME)
+ pkt->flags |= AV_PKT_FLAG_KEY;
+
+ /* if there is a new palette available, add it to packet side data */
+ if (vid->palette) {
+ uint8_t *pdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
+ BVID_PALETTE_SIZE);
+ memcpy(pdata, vid->palette, BVID_PALETTE_SIZE);
+ av_freep(&vid->palette);
+ }
vid->nframes--; // used to check if all the frames were read
- return vidbuf_nbytes;
+ return 0;
fail:
av_free(vidbuf_start);
- return -1;
+ return ret;
}
static int vid_read_packet(AVFormatContext *s,
@@ -185,31 +213,54 @@ static int vid_read_packet(AVFormatContext *s,
block_type = avio_r8(pb);
switch(block_type){
case PALETTE_BLOCK:
- avio_seek(pb, -1, SEEK_CUR); // include block type
- ret_value = av_get_packet(pb, pkt, 3 * 256 + 1);
- if(ret_value != 3 * 256 + 1){
- av_free_packet(pkt);
+ if (vid->palette) {
+ av_log(s, AV_LOG_WARNING, "discarding unused palette\n");
+ av_freep(&vid->palette);
+ }
+ vid->palette = av_malloc(BVID_PALETTE_SIZE);
+ if (!vid->palette)
+ return AVERROR(ENOMEM);
+ if (avio_read(pb, vid->palette, BVID_PALETTE_SIZE) != BVID_PALETTE_SIZE) {
+ av_freep(&vid->palette);
return AVERROR(EIO);
}
- pkt->stream_index = 0;
- return ret_value;
+ return vid_read_packet(s, pkt);
case FIRST_AUDIO_BLOCK:
avio_rl16(pb);
// soundblaster DAC used for sample rate, as on specification page (link above)
- s->streams[1]->codec->sample_rate = 1000000 / (256 - avio_r8(pb));
- s->streams[1]->codec->bit_rate = s->streams[1]->codec->channels * s->streams[1]->codec->sample_rate * s->streams[1]->codec->bits_per_coded_sample;
+ vid->sample_rate = 1000000 / (256 - avio_r8(pb));
case AUDIO_BLOCK:
+ if (vid->audio_index < 0) {
+ AVStream *st = avformat_new_stream(s, NULL);
+ if (!st)
+ return AVERROR(ENOMEM);
+ vid->audio_index = st->index;
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codec->codec_id = CODEC_ID_PCM_U8;
+ st->codec->channels = 1;
+ st->codec->bits_per_coded_sample = 8;
+ st->codec->sample_rate = vid->sample_rate;
+ st->codec->bit_rate = 8 * st->codec->sample_rate;
+ st->start_time = 0;
+ avpriv_set_pts_info(st, 64, 1, vid->sample_rate);
+ }
audio_length = avio_rl16(pb);
- ret_value = av_get_packet(pb, pkt, audio_length);
- pkt->stream_index = 1;
- return ret_value != audio_length ? AVERROR(EIO) : ret_value;
+ if ((ret_value = av_get_packet(pb, pkt, audio_length)) != audio_length) {
+ if (ret_value < 0)
+ return ret_value;
+ av_log(s, AV_LOG_ERROR, "incomplete audio block\n");
+ return AVERROR(EIO);
+ }
+ pkt->stream_index = vid->audio_index;
+ pkt->duration = audio_length;
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ return 0;
case VIDEO_P_FRAME:
case VIDEO_YOFF_P_FRAME:
case VIDEO_I_FRAME:
- return read_frame(vid, pb, pkt, block_type, s,
- s->streams[0]->codec->width * s->streams[0]->codec->height);
+ return read_frame(vid, pb, pkt, block_type, s);
case EOF_BLOCK:
if(vid->nframes != 0)
@@ -218,10 +269,18 @@ static int vid_read_packet(AVFormatContext *s,
return AVERROR(EIO);
default:
av_log(s, AV_LOG_ERROR, "unknown block (character = %c, decimal = %d, hex = %x)!!!\n",
- block_type, block_type, block_type); return -1;
+ block_type, block_type, block_type);
+ return AVERROR_INVALIDDATA;
}
}
+static int vid_read_close(AVFormatContext *s)
+{
+ BVID_DemuxContext *vid = s->priv_data;
+ av_freep(&vid->palette);
+ return 0;
+}
+
AVInputFormat ff_bethsoftvid_demuxer = {
.name = "bethsoftvid",
.long_name = NULL_IF_CONFIG_SMALL("Bethesda Softworks VID format"),
@@ -229,4 +288,5 @@ AVInputFormat ff_bethsoftvid_demuxer = {
.read_probe = vid_probe,
.read_header = vid_read_header,
.read_packet = vid_read_packet,
+ .read_close = vid_read_close,
};
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 449c641e6e..2c96f34a6b 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2230,10 +2230,11 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVTrack *track,
flags |= 0x20; /* default-sample-flags-present */
}
- /* Don't set a default sample size when creating data for silverlight,
- * the player refuses to play files with that set. */
+ /* Don't set a default sample size, the silverlight player refuses
+ * to play files with that set. Don't set a default sample duration,
+ * WMP freaks out if it is set. */
if (track->mode == MODE_ISM)
- flags &= ~0x10;
+ flags &= ~0x18;
avio_wb32(pb, 0); /* size placeholder */
ffio_wfourcc(pb, "tfhd");
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index 2318ff65a1..1ee59877d2 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -333,7 +333,7 @@ static int write_hint_packets(AVIOContext *out, const uint8_t *data,
size -= 4;
if (packet_len > size || packet_len <= 12)
break;
- if (data[1] >= RTCP_SR && data[1] <= RTCP_APP) {
+ if (RTP_PT_IS_RTCP(data[1])) {
/* RTCP packet, just skip */
data += packet_len;
size -= packet_len;
diff --git a/libavformat/rtp.h b/libavformat/rtp.h
index 23588755ec..5cd77fed9b 100644
--- a/libavformat/rtp.h
+++ b/libavformat/rtp.h
@@ -91,4 +91,6 @@ enum RTCPType {
RTCP_APP // 204
};
+#define RTP_PT_IS_RTCP(x) ((x) >= RTCP_SR && (x) <= RTCP_APP)
+
#endif /* AVFORMAT_RTP_H */
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 72b430c423..dae2e581d2 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -695,7 +695,7 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
if ((buf[0] & 0xc0) != (RTP_VERSION << 6))
return -1;
- if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {
+ if (RTP_PT_IS_RTCP(buf[1])) {
return rtcp_parse_packet(s, buf, len);
}
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 4ce1d6bbbb..de7a4013df 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -267,7 +267,7 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size)
int ret;
URLContext *hd;
- if (buf[1] >= RTCP_SR && buf[1] <= RTCP_APP) {
+ if (RTP_PT_IS_RTCP(buf[1])) {
/* RTCP payload type */
hd = s->rtcp_hd;
} else {
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index c3585358e0..bc03db41a9 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1922,6 +1922,9 @@ static int rtp_read_header(AVFormatContext *s)
continue;
}
+ if (RTP_PT_IS_RTCP(recvbuf[1]))
+ continue;
+
payload_type = recvbuf[1] & 0x7f;
break;
}
diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c
index 7bdacc29f7..f3c846a5fb 100644
--- a/libavformat/rtspenc.c
+++ b/libavformat/rtspenc.c
@@ -159,7 +159,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st)
size -= 4;
if (packet_len > size || packet_len < 2)
break;
- if (ptr[1] >= RTCP_SR && ptr[1] <= RTCP_APP)
+ if (RTP_PT_IS_RTCP(ptr[1]))
id = rtsp_st->interleaved_max; /* RTCP */
else
id = rtsp_st->interleaved_min; /* RTP */
diff --git a/tests/ref/fate/bethsoft-vid b/tests/ref/fate/bethsoft-vid
index 7599bf018c..19674270a4 100644
--- a/tests/ref/fate/bethsoft-vid
+++ b/tests/ref/fate/bethsoft-vid
@@ -1,143 +1,144 @@
-#tb 0: 1/60
+#tb 0: 1/14
#tb 1: 1/11111
+0, 0, 0, 1, 192000, 0x00000000
1, 0, 0, 740, 1480, 0x00000000
-0, 1, 1, 1, 192000, 0x00000000
1, 740, 740, 740, 1480, 0x20a92bd4
-0, 5, 5, 1, 192000, 0x5a5acf57
+0, 1, 1, 1, 192000, 0x5a5acf57
1, 1480, 1480, 925, 1850, 0xa9e48a74
-0, 10, 10, 1, 192000, 0xbd055cf1
+0, 2, 2, 1, 192000, 0xbd055cf1
+0, 3, 3, 1, 192000, 0x28b1eefc
1, 2405, 2405, 740, 1480, 0x23ecd018
-0, 14, 14, 1, 192000, 0x28b1eefc
1, 3145, 3145, 740, 1480, 0x206bb915
-0, 18, 18, 1, 192000, 0x0636bacd
+0, 4, 4, 1, 192000, 0x0636bacd
1, 3885, 3885, 925, 1850, 0xb0e10e75
-0, 23, 23, 1, 192000, 0xbfd33cbd
+0, 5, 5, 1, 192000, 0xbfd33cbd
+0, 6, 6, 1, 192000, 0x0bd150ef
1, 4810, 4810, 740, 1480, 0x8d9baedd
-0, 27, 27, 1, 192000, 0x0bd150ef
1, 5550, 5550, 740, 1480, 0xb802aae1
-0, 31, 31, 1, 192000, 0x780d891e
+0, 7, 7, 1, 192000, 0x780d891e
1, 6290, 6290, 740, 1480, 0xecd7b5cc
-0, 35, 35, 1, 192000, 0xacf5e205
+0, 8, 8, 1, 192000, 0xacf5e205
1, 7030, 7030, 925, 1850, 0x16861355
-0, 40, 40, 1, 192000, 0x37c900dc
+0, 9, 9, 1, 192000, 0x37c900dc
+0, 10, 10, 1, 192000, 0x4ee6add7
1, 7955, 7955, 740, 1480, 0xa51690bd
-0, 44, 44, 1, 192000, 0x4ee6add7
1, 8695, 8695, 740, 1480, 0xdd0b90d1
-0, 48, 48, 1, 192000, 0x1844783a
+0, 11, 11, 1, 192000, 0x1844783a
1, 9435, 9435, 925, 1850, 0x3ce6e333
-0, 53, 53, 1, 192000, 0x7bf84848
+0, 12, 12, 1, 192000, 0x7bf84848
+0, 13, 13, 1, 192000, 0x1ec296bc
1, 10360, 10360, 740, 1480, 0xf8ce8ea3
-0, 57, 57, 1, 192000, 0x1ec296bc
1, 11100, 11100, 740, 1480, 0xda4597af
-0, 61, 61, 1, 192000, 0xbaeb5292
+0, 14, 14, 1, 192000, 0xbaeb5292
1, 11840, 11840, 740, 1480, 0x918f7cb3
-0, 65, 65, 1, 192000, 0xcb18038d
+0, 15, 15, 1, 192000, 0xcb18038d
1, 12580, 12580, 925, 1850, 0xca6edb15
-0, 70, 70, 1, 192000, 0xb3cc8b65
+0, 16, 16, 1, 192000, 0xb3cc8b65
+0, 17, 17, 1, 192000, 0x6f164685
1, 13505, 13505, 740, 1480, 0xba279597
-0, 74, 74, 1, 192000, 0x6f164685
1, 14245, 14245, 740, 1480, 0xc5a38a9e
-0, 78, 78, 1, 192000, 0x304917c9
+0, 18, 18, 1, 192000, 0x304917c9
1, 14985, 14985, 925, 1850, 0x8147eef5
-0, 83, 83, 1, 192000, 0x8269daa1
+0, 19, 19, 1, 192000, 0x8269daa1
+0, 20, 20, 1, 192000, 0x04d3500d
1, 15910, 15910, 740, 1480, 0xce2c7cb5
-0, 87, 87, 1, 192000, 0x04d3500d
1, 16650, 16650, 740, 1480, 0x4282819f
-0, 91, 91, 1, 192000, 0x9788f7a5
+0, 21, 21, 1, 192000, 0x9788f7a5
1, 17390, 17390, 740, 1480, 0xbdbb8da6
-0, 95, 95, 1, 192000, 0x05351c98
+0, 22, 22, 1, 192000, 0x05351c98
1, 18130, 18130, 925, 1850, 0xdbbeea10
-0, 100, 100, 1, 192000, 0xcc8bba97
+0, 23, 23, 1, 192000, 0xcc8bba97
+0, 24, 24, 1, 192000, 0x76caf27b
1, 19055, 19055, 740, 1480, 0xbe6a77c2
-0, 104, 104, 1, 192000, 0x76caf27b
1, 19795, 19795, 740, 1480, 0xa85c75b2
-0, 108, 108, 1, 192000, 0x28648040
+0, 25, 25, 1, 192000, 0x28648040
1, 20535, 20535, 925, 1850, 0xa45bde21
-0, 113, 113, 1, 192000, 0x99ea251f
+0, 26, 26, 1, 192000, 0x99ea251f
+0, 27, 27, 1, 192000, 0x20e7bf4d
1, 21460, 21460, 740, 1480, 0x84aa7895
-0, 117, 117, 1, 192000, 0x20e7bf4d
1, 22200, 22200, 740, 1480, 0x147f7d9f
-0, 121, 121, 1, 192000, 0x046ed625
+0, 28, 28, 1, 192000, 0x046ed625
1, 22940, 22940, 740, 1480, 0xc8e77b85
-0, 125, 125, 1, 192000, 0x1613fb12
+0, 29, 29, 1, 192000, 0x1613fb12
1, 23680, 23680, 925, 1850, 0x10d4d81b
-0, 130, 130, 1, 192000, 0xd8b52d16
+0, 30, 30, 1, 192000, 0xd8b52d16
+0, 31, 31, 1, 192000, 0x31443aa9
1, 24605, 24605, 740, 1480, 0xb4ae8bb1
-0, 134, 134, 1, 192000, 0x31443aa9
1, 25345, 25345, 740, 1480, 0x3ef782a5
-0, 138, 138, 1, 192000, 0xd426de3d
+0, 32, 32, 1, 192000, 0xd426de3d
1, 26085, 26085, 925, 1850, 0xdeebda14
-0, 143, 143, 1, 192000, 0xb2bce77b
+0, 33, 33, 1, 192000, 0xb2bce77b
+0, 34, 34, 1, 192000, 0x25a52805
1, 27010, 27010, 740, 1480, 0x4c7e7bbb
-0, 147, 147, 1, 192000, 0x25a52805
1, 27750, 27750, 740, 1480, 0x0e0e9198
-0, 151, 151, 1, 192000, 0x04f03a87
+0, 35, 35, 1, 192000, 0x04f03a87
1, 28490, 28490, 740, 1480, 0x5c1f819f
-0, 155, 155, 1, 192000, 0x41d56889
+0, 36, 36, 1, 192000, 0x41d56889
1, 29230, 29230, 925, 1850, 0x0e4cf6ff
-0, 160, 160, 1, 192000, 0x3d4d6de9
+0, 37, 37, 1, 192000, 0x3d4d6de9
1, 30155, 30155, 740, 1480, 0x374388a7
-0, 164, 164, 1, 192000, 0xa7a2abfe
+0, 38, 38, 1, 192000, 0xa7a2abfe
1, 30895, 30895, 740, 1480, 0xed729389
-0, 168, 168, 1, 192000, 0x663e9fca
+0, 39, 39, 1, 192000, 0x663e9fca
1, 31635, 31635, 925, 1850, 0xe0f1e43f
-0, 173, 173, 1, 192000, 0x29a67f86
+0, 40, 40, 1, 192000, 0x29a67f86
+0, 41, 41, 1, 192000, 0x51531bb0
1, 32560, 32560, 740, 1480, 0x3b27839a
-0, 177, 177, 1, 192000, 0x51531bb0
1, 33300, 33300, 740, 1480, 0xe6287e94
-0, 181, 181, 1, 192000, 0xd993277e
+0, 42, 42, 1, 192000, 0xd993277e
1, 34040, 34040, 740, 1480, 0x7e0d84b5
-0, 185, 185, 1, 192000, 0x4873e583
+0, 43, 43, 1, 192000, 0x4873e583
1, 34780, 34780, 925, 1850, 0xf08bebf7
-0, 190, 190, 1, 192000, 0x06df053b
+0, 44, 44, 1, 192000, 0x06df053b
1, 35705, 35705, 740, 1480, 0x94cf73a0
-0, 194, 194, 1, 192000, 0x044f7698
+0, 45, 45, 1, 192000, 0x044f7698
1, 36445, 36445, 740, 1480, 0xfef384ae
-0, 198, 198, 1, 192000, 0xc2302a45
+0, 46, 46, 1, 192000, 0xc2302a45
1, 37185, 37185, 925, 1850, 0x3b93e0f7
-0, 203, 203, 1, 192000, 0xbdfec8ee
+0, 47, 47, 1, 192000, 0xbdfec8ee
+0, 48, 48, 1, 192000, 0x3b739286
1, 38110, 38110, 740, 1480, 0x28d27bae
-0, 207, 207, 1, 192000, 0x3b739286
1, 38850, 38850, 740, 1480, 0x94d57da5
-0, 211, 211, 1, 192000, 0x3ca82cd6
+0, 49, 49, 1, 192000, 0x3ca82cd6
1, 39590, 39590, 740, 1480, 0xc9327db5
-0, 215, 215, 1, 192000, 0x25af10f2
+0, 50, 50, 1, 192000, 0x25af10f2
1, 40330, 40330, 925, 1850, 0xe781f604
-0, 220, 220, 1, 192000, 0x09ce32bf
+0, 51, 51, 1, 192000, 0x09ce32bf
1, 41255, 41255, 740, 1480, 0x752f8c5b
-0, 224, 224, 1, 192000, 0xdab399c2
+0, 52, 52, 1, 192000, 0xdab399c2
1, 41995, 41995, 740, 1480, 0x30068032
-0, 228, 228, 1, 192000, 0x77400d93
+0, 53, 53, 1, 192000, 0x77400d93
1, 42735, 42735, 925, 1850, 0x7895023e
-0, 233, 233, 1, 192000, 0x5e8e6fe7
+0, 54, 54, 1, 192000, 0x5e8e6fe7
+0, 55, 55, 1, 192000, 0x277506c9
1, 43660, 43660, 740, 1480, 0xa1e0a6e1
-0, 237, 237, 1, 192000, 0x277506c9
1, 44400, 44400, 740, 1480, 0x6af4b500
-0, 241, 241, 1, 192000, 0xe91b59ac
+0, 56, 56, 1, 192000, 0xe91b59ac
1, 45140, 45140, 740, 1480, 0xc26ea4c7
-0, 245, 245, 1, 192000, 0xc2aa6e19
+0, 57, 57, 1, 192000, 0xc2aa6e19
1, 45880, 45880, 925, 1850, 0x16a72419
-0, 250, 250, 1, 192000, 0x12c63645
+0, 58, 58, 1, 192000, 0x12c63645
1, 46805, 46805, 740, 1480, 0x1794aacc
-0, 254, 254, 1, 192000, 0xa39f27d6
+0, 59, 59, 1, 192000, 0xa39f27d6
1, 47545, 47545, 740, 1480, 0x2ecad8d0
-0, 258, 258, 1, 192000, 0x20c32512
+0, 60, 60, 1, 192000, 0x20c32512
1, 48285, 48285, 925, 1850, 0x2e645e07
-0, 263, 263, 1, 192000, 0x385a26a0
+0, 61, 61, 1, 192000, 0x385a26a0
+0, 62, 62, 1, 192000, 0x2566a70c
1, 49210, 49210, 740, 1480, 0x1c54dfe7
-0, 267, 267, 1, 192000, 0x2566a70c
1, 49950, 49950, 740, 1480, 0xbd35feec
-0, 271, 271, 1, 192000, 0x7105cfb9
+0, 63, 63, 1, 192000, 0x7105cfb9
1, 50690, 50690, 740, 1480, 0x419403d6
-0, 275, 275, 1, 192000, 0x725671a2
+0, 64, 64, 1, 192000, 0x725671a2
1, 51430, 51430, 925, 1850, 0x78699d2a
-0, 280, 280, 1, 192000, 0x3ff2782a
+0, 65, 65, 1, 192000, 0x3ff2782a
1, 52355, 52355, 740, 1480, 0x74ec68e0
-0, 284, 284, 1, 192000, 0xdc0571c3
+0, 66, 66, 1, 192000, 0xdc0571c3
1, 53095, 53095, 740, 1480, 0x76af64d9
-0, 288, 288, 1, 192000, 0x4a6a5405
+0, 67, 67, 1, 192000, 0x4a6a5405
1, 53835, 53835, 925, 1850, 0x5a303d1a
-0, 293, 293, 1, 192000, 0x3ec3cce1
+0, 68, 68, 1, 192000, 0x3ec3cce1
1, 54760, 54760, 537, 1074, 0x142ce7ba
-0, 297, 297, 1, 192000, 0x159313a8
+0, 69, 69, 1, 192000, 0x159313a8
1, 55297, 55297, 925, 1850, 0x7ff682f7
+0, 70, 70, 1, 192000, 0x8e685d68