avcodec/mpegvideo: Remove pblocks
It has been added in a579db0c4fe026d49c71d1ff64a2d1d07c152d68 due to XvMC, but today it is only used to swap U and V for VCR2, a MPEG-2 variant with U and V swapped. This can be done in a simpler fashion, namely by simply swapping the U and V pointers of the corresponding MPVWorkPictures. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
1f5c64cbdc
commit
2f6768c761
@ -535,14 +535,14 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
|
|||||||
|
|
||||||
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
|
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
|
||||||
for (i = 0; i < mb_block_count; i++)
|
for (i = 0; i < mb_block_count; i++)
|
||||||
if ((ret = mpeg2_decode_block_intra(s, *s->pblocks[i], i)) < 0)
|
if ((ret = mpeg2_decode_block_intra(s, s->block[i], i)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
ret = ff_mpeg1_decode_block_intra(&s->gb,
|
ret = ff_mpeg1_decode_block_intra(&s->gb,
|
||||||
s->intra_matrix,
|
s->intra_matrix,
|
||||||
s->intra_scantable.permutated,
|
s->intra_scantable.permutated,
|
||||||
s->last_dc, *s->pblocks[i],
|
s->last_dc, s->block[i],
|
||||||
i, s->qscale);
|
i, s->qscale);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n",
|
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n",
|
||||||
@ -760,7 +760,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
|
|||||||
|
|
||||||
for (i = 0; i < mb_block_count; i++) {
|
for (i = 0; i < mb_block_count; i++) {
|
||||||
if (cbp & (1 << 11)) {
|
if (cbp & (1 << 11)) {
|
||||||
if ((ret = mpeg2_decode_block_non_intra(s, *s->pblocks[i], i)) < 0)
|
if ((ret = mpeg2_decode_block_non_intra(s, s->block[i], i)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
s->block_last_index[i] = -1;
|
s->block_last_index[i] = -1;
|
||||||
@ -770,7 +770,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
|
|||||||
} else {
|
} else {
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
if (cbp & 32) {
|
if (cbp & 32) {
|
||||||
if ((ret = mpeg1_decode_block_inter(s, *s->pblocks[i], i)) < 0)
|
if ((ret = mpeg1_decode_block_inter(s, s->block[i], i)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
s->block_last_index[i] = -1;
|
s->block_last_index[i] = -1;
|
||||||
@ -1279,6 +1279,7 @@ static int mpeg_field_start(Mpeg1Context *s1, const uint8_t *buf, int buf_size)
|
|||||||
{
|
{
|
||||||
MpegEncContext *s = &s1->mpeg_enc_ctx;
|
MpegEncContext *s = &s1->mpeg_enc_ctx;
|
||||||
AVCodecContext *avctx = s->avctx;
|
AVCodecContext *avctx = s->avctx;
|
||||||
|
int second_field = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
|
if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
|
||||||
@ -1362,6 +1363,7 @@ static int mpeg_field_start(Mpeg1Context *s1, const uint8_t *buf, int buf_size)
|
|||||||
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
|
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
|
||||||
ff_thread_finish_setup(avctx);
|
ff_thread_finish_setup(avctx);
|
||||||
} else { // second field
|
} else { // second field
|
||||||
|
second_field = 1;
|
||||||
if (!s->cur_pic.ptr) {
|
if (!s->cur_pic.ptr) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");
|
av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
@ -1389,6 +1391,16 @@ static int mpeg_field_start(Mpeg1Context *s1, const uint8_t *buf, int buf_size)
|
|||||||
if (avctx->hwaccel) {
|
if (avctx->hwaccel) {
|
||||||
if ((ret = FF_HW_CALL(avctx, start_frame, buf, buf_size)) < 0)
|
if ((ret = FF_HW_CALL(avctx, start_frame, buf, buf_size)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
} else if (s->codec_tag == MKTAG('V', 'C', 'R', '2')) {
|
||||||
|
// Exchange UV
|
||||||
|
FFSWAP(uint8_t*, s->cur_pic.data[1], s->cur_pic.data[2]);
|
||||||
|
FFSWAP(ptrdiff_t, s->cur_pic.linesize[1], s->cur_pic.linesize[2]);
|
||||||
|
if (!second_field) {
|
||||||
|
FFSWAP(uint8_t*, s->next_pic.data[1], s->next_pic.data[2]);
|
||||||
|
FFSWAP(ptrdiff_t, s->next_pic.linesize[1], s->next_pic.linesize[2]);
|
||||||
|
FFSWAP(uint8_t*, s->last_pic.data[1], s->last_pic.data[2]);
|
||||||
|
FFSWAP(ptrdiff_t, s->last_pic.linesize[1], s->last_pic.linesize[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -365,8 +365,6 @@ av_cold void ff_mpv_idct_init(MpegEncContext *s)
|
|||||||
|
|
||||||
static int init_duplicate_context(MpegEncContext *s)
|
static int init_duplicate_context(MpegEncContext *s)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (s->encoding) {
|
if (s->encoding) {
|
||||||
s->me.map = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->me.map));
|
s->me.map = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->me.map));
|
||||||
if (!s->me.map)
|
if (!s->me.map)
|
||||||
@ -382,15 +380,6 @@ static int init_duplicate_context(MpegEncContext *s)
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
s->block = s->blocks[0];
|
s->block = s->blocks[0];
|
||||||
|
|
||||||
for (i = 0; i < 12; i++) {
|
|
||||||
s->pblocks[i] = &s->block[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->avctx->codec_tag == AV_RL32("VCR2")) {
|
|
||||||
// exchange uv
|
|
||||||
FFSWAP(void *, s->pblocks[4], s->pblocks[5]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->out_format == FMT_H263) {
|
if (s->out_format == FMT_H263) {
|
||||||
int mb_height = s->msmpeg4_version == 6 /* VC-1 like */ ?
|
int mb_height = s->msmpeg4_version == 6 /* VC-1 like */ ?
|
||||||
FFALIGN(s->mb_height, 2) : s->mb_height;
|
FFALIGN(s->mb_height, 2) : s->mb_height;
|
||||||
@ -484,18 +473,12 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src)
|
|||||||
int ff_update_duplicate_context(MpegEncContext *dst, const MpegEncContext *src)
|
int ff_update_duplicate_context(MpegEncContext *dst, const MpegEncContext *src)
|
||||||
{
|
{
|
||||||
MpegEncContext bak;
|
MpegEncContext bak;
|
||||||
int i, ret;
|
int ret;
|
||||||
// FIXME copy only needed parts
|
// FIXME copy only needed parts
|
||||||
backup_duplicate_context(&bak, dst);
|
backup_duplicate_context(&bak, dst);
|
||||||
memcpy(dst, src, sizeof(MpegEncContext));
|
memcpy(dst, src, sizeof(MpegEncContext));
|
||||||
backup_duplicate_context(dst, &bak);
|
backup_duplicate_context(dst, &bak);
|
||||||
for (i = 0; i < 12; i++) {
|
|
||||||
dst->pblocks[i] = &dst->block[i];
|
|
||||||
}
|
|
||||||
if (dst->avctx->codec_tag == AV_RL32("VCR2")) {
|
|
||||||
// exchange uv
|
|
||||||
FFSWAP(void *, dst->pblocks[4], dst->pblocks[5]);
|
|
||||||
}
|
|
||||||
ret = ff_mpv_framesize_alloc(dst->avctx, &dst->sc, dst->linesize);
|
ret = ff_mpv_framesize_alloc(dst->avctx, &dst->sc, dst->linesize);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(dst->avctx, AV_LOG_ERROR, "failed to allocate context "
|
av_log(dst->avctx, AV_LOG_ERROR, "failed to allocate context "
|
||||||
@ -682,7 +665,6 @@ static void clear_context(MpegEncContext *s)
|
|||||||
s->dct_error_sum = NULL;
|
s->dct_error_sum = NULL;
|
||||||
s->block = NULL;
|
s->block = NULL;
|
||||||
s->blocks = NULL;
|
s->blocks = NULL;
|
||||||
memset(s->pblocks, 0, sizeof(s->pblocks));
|
|
||||||
s->ac_val_base = NULL;
|
s->ac_val_base = NULL;
|
||||||
s->ac_val[0] =
|
s->ac_val[0] =
|
||||||
s->ac_val[1] =
|
s->ac_val[1] =
|
||||||
|
@ -466,7 +466,6 @@ typedef struct MpegEncContext {
|
|||||||
int rtp_payload_size;
|
int rtp_payload_size;
|
||||||
|
|
||||||
uint8_t *ptr_lastgob;
|
uint8_t *ptr_lastgob;
|
||||||
int16_t (*pblocks[12])[64];
|
|
||||||
|
|
||||||
int16_t (*block)[64]; ///< points to one of the following blocks
|
int16_t (*block)[64]; ///< points to one of the following blocks
|
||||||
int16_t (*blocks)[12][64]; // for HQ mode we need to keep the best block
|
int16_t (*blocks)[12][64]; // for HQ mode we need to keep the best block
|
||||||
|
Loading…
x
Reference in New Issue
Block a user