Commit 8c1ebdce authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  shorten: Use separate pointers for the allocated memory for decoded samples.
  atrac3: Fix crash in tonal component decoding.
  ws_snd1: Fix wrong samples counts.
  movenc: Don't set a default sample duration when creating ismv
  rtp: Factorize the check for distinguishing RTCP packets from RTP
  golomb: avoid infinite loop on all-zero input (or end of buffer).
  bethsoftvid: synchronize video timestamps with audio sample rate
  bethsoftvid: add audio stream only after getting the first audio packet
  bethsoftvid: Set video packet duration instead of accumulating pts.
  bethsoftvid: set packet key frame flag for audio and I-frame video packets.
  bethsoftvid: fix read_packet() return codes.
  bethsoftvid: pass palette in side data instead of in a separate packet.
  sdp: Ignore RTCP packets when autodetecting RTP streams
  proresenc: initialise 'sign' variable
  mpegaudio: replace memcpy by SIMD code
  vc1: prevent using last_frame as a reference for I/P first frame.

Conflicts:
	libavcodec/atrac3.c
	libavcodec/golomb.h
	libavcodec/shorten.c
	libavcodec/ws-snd1.c
	tests/ref/fate/bethsoft-vid
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 7bdefc0f 204cb29b
......@@ -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);
......
......@@ -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;
......
......@@ -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");
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
This diff is collapsed.
......@@ -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");
......
......@@ -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;
......
......@@ -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 */
......@@ -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);
}
......
......@@ -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 {
......
......@@ -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;
}
......
......@@ -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 */
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment