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

Merge commit 'd9ebb00d'

* commit 'd9ebb00d':
  svq3: remove a pointless if()
  h264: remove a pointless if()

Conflicts:
	libavcodec/h264.c
	libavcodec/svq3.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 131b9c92 d9ebb00d
...@@ -1822,77 +1822,75 @@ static av_always_inline void hl_decode_mb_predict_luma(H264Context *h, ...@@ -1822,77 +1822,75 @@ static av_always_inline void hl_decode_mb_predict_luma(H264Context *h,
int qscale = p == 0 ? s->qscale : h->chroma_qp[p - 1]; int qscale = p == 0 ? s->qscale : h->chroma_qp[p - 1];
block_offset += 16 * p; block_offset += 16 * p;
if (IS_INTRA4x4(mb_type)) { if (IS_INTRA4x4(mb_type)) {
if (simple || !s->encoding) { if (IS_8x8DCT(mb_type)) {
if (IS_8x8DCT(mb_type)) { if (transform_bypass) {
if (transform_bypass) { idct_dc_add =
idct_dc_add = idct_add = h->h264dsp.h264_add_pixels8;
idct_add = h->h264dsp.h264_add_pixels8; } else {
idct_dc_add = h->h264dsp.h264_idct8_dc_add;
idct_add = h->h264dsp.h264_idct8_add;
}
for (i = 0; i < 16; i += 4) {
uint8_t *const ptr = dest_y + block_offset[i];
const int dir = h->intra4x4_pred_mode_cache[scan8[i]];
if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
h->hpc.pred8x8l_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
} else { } else {
idct_dc_add = h->h264dsp.h264_idct8_dc_add; const int nnz = h->non_zero_count_cache[scan8[i + p * 16]];
idct_add = h->h264dsp.h264_idct8_add; h->hpc.pred8x8l[dir](ptr, (h->topleft_samples_available << i) & 0x8000,
} (h->topright_samples_available << i) & 0x4000, linesize);
for (i = 0; i < 16; i += 4) { if (nnz) {
uint8_t *const ptr = dest_y + block_offset[i]; if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
const int dir = h->intra4x4_pred_mode_cache[scan8[i]]; idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) { else
h->hpc.pred8x8l_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
} else {
const int nnz = h->non_zero_count_cache[scan8[i + p * 16]];
h->hpc.pred8x8l[dir](ptr, (h->topleft_samples_available << i) & 0x8000,
(h->topright_samples_available << i) & 0x4000, linesize);
if (nnz) {
if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
else
idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
}
} }
} }
}
} else {
if (transform_bypass) {
idct_dc_add =
idct_add = h->h264dsp.h264_add_pixels4;
} else { } else {
if (transform_bypass) { idct_dc_add = h->h264dsp.h264_idct_dc_add;
idct_dc_add = idct_add = h->h264dsp.h264_idct_add;
idct_add = h->h264dsp.h264_add_pixels4; }
} else { for (i = 0; i < 16; i++) {
idct_dc_add = h->h264dsp.h264_idct_dc_add; uint8_t *const ptr = dest_y + block_offset[i];
idct_add = h->h264dsp.h264_idct_add; const int dir = h->intra4x4_pred_mode_cache[scan8[i]];
}
for (i = 0; i < 16; i++) {
uint8_t *const ptr = dest_y + block_offset[i];
const int dir = h->intra4x4_pred_mode_cache[scan8[i]];
if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) { if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
h->hpc.pred4x4_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); h->hpc.pred4x4_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
} else { } else {
uint8_t *topright; uint8_t *topright;
int nnz, tr; int nnz, tr;
uint64_t tr_high; uint64_t tr_high;
if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) { if (dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED) {
const int topright_avail = (h->topright_samples_available << i) & 0x8000; const int topright_avail = (h->topright_samples_available << i) & 0x8000;
av_assert2(s->mb_y || linesize <= block_offset[i]); av_assert2(s->mb_y || linesize <= block_offset[i]);
if (!topright_avail) { if (!topright_avail) {
if (pixel_shift) { if (pixel_shift) {
tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL; tr_high = ((uint16_t *)ptr)[3 - linesize / 2] * 0x0001000100010001ULL;
topright = (uint8_t *)&tr_high; topright = (uint8_t *)&tr_high;
} else { } else {
tr = ptr[3 - linesize] * 0x01010101u; tr = ptr[3 - linesize] * 0x01010101u;
topright = (uint8_t *)&tr; topright = (uint8_t *)&tr;
} }
} else
topright = ptr + (4 << pixel_shift) - linesize;
} else } else
topright = NULL; topright = ptr + (4 << pixel_shift) - linesize;
} else
h->hpc.pred4x4[dir](ptr, topright, linesize); topright = NULL;
nnz = h->non_zero_count_cache[scan8[i + p * 16]];
if (nnz) { h->hpc.pred4x4[dir](ptr, topright, linesize);
if (is_h264) { nnz = h->non_zero_count_cache[scan8[i + p * 16]];
if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256)) if (nnz) {
idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); if (is_h264) {
else if (nnz == 1 && dctcoef_get(h->mb, pixel_shift, i * 16 + p * 256))
idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize); idct_dc_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
} else if (CONFIG_SVQ3_DECODER) else
ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize, qscale, 0); idct_add(ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
} } else if (CONFIG_SVQ3_DECODER)
ff_svq3_add_idct_c(ptr, h->mb + i * 16 + p * 256, linesize, qscale, 0);
} }
} }
} }
......
...@@ -863,148 +863,145 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) ...@@ -863,148 +863,145 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
h->sps.chroma_format_idc = 1; h->sps.chroma_format_idc = 1;
avctx->pix_fmt = avctx->codec->pix_fmts[0]; avctx->pix_fmt = avctx->codec->pix_fmts[0];
if (!s->context_initialized) { h->chroma_qp[0] = h->chroma_qp[1] = 4;
h->chroma_qp[0] = h->chroma_qp[1] = 4;
svq3->halfpel_flag = 1;
svq3->halfpel_flag = 1; svq3->thirdpel_flag = 1;
svq3->thirdpel_flag = 1; svq3->unknown_flag = 0;
svq3->unknown_flag = 0;
/* prowl for the "SEQH" marker in the extradata */
extradata = (unsigned char *)avctx->extradata;
/* prowl for the "SEQH" marker in the extradata */ extradata_end = avctx->extradata + avctx->extradata_size;
extradata = (unsigned char *)avctx->extradata; if (extradata) {
extradata_end = avctx->extradata + avctx->extradata_size; for (m = 0; m + 8 < avctx->extradata_size; m++) {
if (extradata) { if (!memcmp(extradata, "SEQH", 4)) {
for (m = 0; m + 8 < avctx->extradata_size; m++) { marker_found = 1;
if (!memcmp(extradata, "SEQH", 4)) { break;
marker_found = 1;
break;
}
extradata++;
} }
extradata++;
} }
}
/* if a match was found, parse the extra data */ /* if a match was found, parse the extra data */
if (marker_found) { if (marker_found) {
GetBitContext gb; GetBitContext gb;
int frame_size_code; int frame_size_code;
size = AV_RB32(&extradata[4]); size = AV_RB32(&extradata[4]);
if (size > extradata_end - extradata - 8) if (size > extradata_end - extradata - 8)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
init_get_bits(&gb, extradata + 8, size * 8); init_get_bits(&gb, extradata + 8, size * 8);
/* 'frame size code' and optional 'width, height' */ /* 'frame size code' and optional 'width, height' */
frame_size_code = get_bits(&gb, 3); frame_size_code = get_bits(&gb, 3);
switch (frame_size_code) { switch (frame_size_code) {
case 0: case 0:
avctx->width = 160; avctx->width = 160;
avctx->height = 120; avctx->height = 120;
break; break;
case 1: case 1:
avctx->width = 128; avctx->width = 128;
avctx->height = 96; avctx->height = 96;
break; break;
case 2: case 2:
avctx->width = 176; avctx->width = 176;
avctx->height = 144; avctx->height = 144;
break; break;
case 3: case 3:
avctx->width = 352; avctx->width = 352;
avctx->height = 288; avctx->height = 288;
break; break;
case 4: case 4:
avctx->width = 704; avctx->width = 704;
avctx->height = 576; avctx->height = 576;
break; break;
case 5: case 5:
avctx->width = 240; avctx->width = 240;
avctx->height = 180; avctx->height = 180;
break; break;
case 6: case 6:
avctx->width = 320; avctx->width = 320;
avctx->height = 240; avctx->height = 240;
break; break;
case 7: case 7:
avctx->width = get_bits(&gb, 12); avctx->width = get_bits(&gb, 12);
avctx->height = get_bits(&gb, 12); avctx->height = get_bits(&gb, 12);
break; break;
} }
svq3->halfpel_flag = get_bits1(&gb); svq3->halfpel_flag = get_bits1(&gb);
svq3->thirdpel_flag = get_bits1(&gb); svq3->thirdpel_flag = get_bits1(&gb);
/* unknown fields */ /* unknown fields */
skip_bits1(&gb); skip_bits1(&gb);
skip_bits1(&gb); skip_bits1(&gb);
skip_bits1(&gb); skip_bits1(&gb);
skip_bits1(&gb); skip_bits1(&gb);
s->low_delay = get_bits1(&gb); s->low_delay = get_bits1(&gb);
/* unknown field */ /* unknown field */
skip_bits1(&gb); skip_bits1(&gb);
while (get_bits1(&gb)) while (get_bits1(&gb))
skip_bits(&gb, 8); skip_bits(&gb, 8);
svq3->unknown_flag = get_bits1(&gb); svq3->unknown_flag = get_bits1(&gb);
avctx->has_b_frames = !s->low_delay; avctx->has_b_frames = !s->low_delay;
if (svq3->unknown_flag) { if (svq3->unknown_flag) {
#if CONFIG_ZLIB #if CONFIG_ZLIB
unsigned watermark_width = svq3_get_ue_golomb(&gb); unsigned watermark_width = svq3_get_ue_golomb(&gb);
unsigned watermark_height = svq3_get_ue_golomb(&gb); unsigned watermark_height = svq3_get_ue_golomb(&gb);
int u1 = svq3_get_ue_golomb(&gb); int u1 = svq3_get_ue_golomb(&gb);
int u2 = get_bits(&gb, 8); int u2 = get_bits(&gb, 8);
int u3 = get_bits(&gb, 2); int u3 = get_bits(&gb, 2);
int u4 = svq3_get_ue_golomb(&gb); int u4 = svq3_get_ue_golomb(&gb);
unsigned long buf_len = watermark_width * unsigned long buf_len = watermark_width *
watermark_height * 4; watermark_height * 4;
int offset = get_bits_count(&gb) + 7 >> 3; int offset = get_bits_count(&gb) + 7 >> 3;
uint8_t *buf; uint8_t *buf;
if (watermark_height <= 0 || (uint64_t)watermark_width*4 > UINT_MAX/watermark_height) if (watermark_height <= 0 || (uint64_t)watermark_width*4 > UINT_MAX/watermark_height)
return -1; return -1;
buf = av_malloc(buf_len); buf = av_malloc(buf_len);
av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n", av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n",
watermark_width, watermark_height); watermark_width, watermark_height);
av_log(avctx, AV_LOG_DEBUG, av_log(avctx, AV_LOG_DEBUG,
"u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n", "u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n",
u1, u2, u3, u4, offset); u1, u2, u3, u4, offset);
if (uncompress(buf, &buf_len, extradata + 8 + offset, if (uncompress(buf, &buf_len, extradata + 8 + offset,
size - offset) != Z_OK) { size - offset) != Z_OK) {
av_log(avctx, AV_LOG_ERROR,
"could not uncompress watermark logo\n");
av_free(buf);
return -1;
}
svq3->watermark_key = ff_svq1_packet_checksum(buf, buf_len, 0);
svq3->watermark_key = svq3->watermark_key << 16 |
svq3->watermark_key;
av_log(avctx, AV_LOG_DEBUG,
"watermark key %#x\n", svq3->watermark_key);
av_free(buf);
#else
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"this svq3 file contains watermark which need zlib support compiled in\n"); "could not uncompress watermark logo\n");
av_free(buf);
return -1; return -1;
#endif
} }
svq3->watermark_key = ff_svq1_packet_checksum(buf, buf_len, 0);
svq3->watermark_key = svq3->watermark_key << 16 |
svq3->watermark_key;
av_log(avctx, AV_LOG_DEBUG,
"watermark key %#x\n", svq3->watermark_key);
av_free(buf);
#else
av_log(avctx, AV_LOG_ERROR,
"this svq3 file contains watermark which need zlib support compiled in\n");
return -1;
#endif
} }
}
s->width = avctx->width; s->width = avctx->width;
s->height = avctx->height; s->height = avctx->height;
if (ff_MPV_common_init(s) < 0) if (ff_MPV_common_init(s) < 0)
return -1; return -1;
h->b_stride = 4 * s->mb_width; h->b_stride = 4 * s->mb_width;
if (ff_h264_alloc_tables(h) < 0) { if (ff_h264_alloc_tables(h) < 0) {
av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n"); av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n");
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
}
} }
return 0; return 0;
......
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