Commit a9a6d51c authored by James Almer's avatar James Almer

avcodec/theora: export cropping information instead of handling it internally

This merges commit 1202b712 from libav,
originally written by Anton Khirnov and skipped in
fc63d5ce.

 libavcodec/vp3.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)
parent 07596e45
...@@ -2003,6 +2003,7 @@ static int vp3_decode_frame(AVCodecContext *avctx, ...@@ -2003,6 +2003,7 @@ static int vp3_decode_frame(AVCodecContext *avctx,
void *data, int *got_frame, void *data, int *got_frame,
AVPacket *avpkt) AVPacket *avpkt)
{ {
AVFrame *frame = data;
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
Vp3DecodeContext *s = avctx->priv_data; Vp3DecodeContext *s = avctx->priv_data;
...@@ -2176,12 +2177,12 @@ static int vp3_decode_frame(AVCodecContext *avctx, ...@@ -2176,12 +2177,12 @@ static int vp3_decode_frame(AVCodecContext *avctx,
/* output frame, offset as needed */ /* output frame, offset as needed */
if ((ret = av_frame_ref(data, s->current_frame.f)) < 0) if ((ret = av_frame_ref(data, s->current_frame.f)) < 0)
return ret; return ret;
for (i = 0; i < 3; i++) {
AVFrame *dst = data; frame->crop_left = s->offset_x;
int off = (s->offset_x >> (i && s->chroma_y_shift)) + frame->crop_right = avctx->coded_width - avctx->width - s->offset_x;
(s->offset_y >> (i && s->chroma_y_shift)) * dst->linesize[i]; frame->crop_top = s->offset_y;
dst->data[i] += off; frame->crop_bottom = avctx->coded_height - avctx->height - s->offset_y;
}
*got_frame = 1; *got_frame = 1;
if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) { if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
...@@ -2351,16 +2352,6 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) ...@@ -2351,16 +2352,6 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
// to normal axis ([0,0] upper left) // to normal axis ([0,0] upper left)
s->offset_x = offset_x; s->offset_x = offset_x;
s->offset_y = s->height - visible_height - offset_y; s->offset_y = s->height - visible_height - offset_y;
if ((s->offset_x & 0x1F) && !(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) {
s->offset_x &= ~0x1F;
if (!s->offset_x_warned) {
s->offset_x_warned = 1;
av_log(avctx, AV_LOG_WARNING, "Reducing offset_x from %d to %d"
"chroma samples to preserve alignment.\n",
offset_x, s->offset_x);
}
}
} }
if (colorspace == 1) if (colorspace == 1)
...@@ -2573,7 +2564,8 @@ AVCodec ff_theora_decoder = { ...@@ -2573,7 +2564,8 @@ AVCodec ff_theora_decoder = {
AV_CODEC_CAP_FRAME_THREADS, AV_CODEC_CAP_FRAME_THREADS,
.flush = vp3_decode_flush, .flush = vp3_decode_flush,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context),
.caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING,
}; };
#endif #endif
......
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