Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-12-06 15:21:31 +0400
committerMichael Niedermayer <michaelni@gmx.at>2013-12-06 16:30:23 +0400
commit93947d88f2abdf17d374a2d83cdb051ef9bafb2c (patch)
tree4e1f967ed1e56ae70d3df7eaa7de32c20f905db6 /libavcodec/mjpegenc.c
parentd756b2b530ca742ac930ca6e9d1ba86ec8af86c9 (diff)
parent24abd806ea0cfb0d988d2f0044eac79cff12918c (diff)
Merge commit '24abd806ea0cfb0d988d2f0044eac79cff12918c'
* commit '24abd806ea0cfb0d988d2f0044eac79cff12918c': ljpegenc: deMpegEncContextize Conflicts: libavcodec/ljpegenc.c libavcodec/mpegvideo.h libavcodec/mpegvideo_enc.c tests/ref/vsynth/vsynth1-ljpeg tests/ref/vsynth/vsynth2-ljpeg Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mjpegenc.c')
-rw-r--r--libavcodec/mjpegenc.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 423a2f5c23..a25af70722 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -212,15 +212,13 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
const int lossless = avctx->codec_id != AV_CODEC_ID_MJPEG;
int hsample[3], vsample[3];
int i;
- MpegEncContext *s = avctx->priv_data;
- av_assert0(avctx->codec->priv_data_size == sizeof(MpegEncContext));
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
&chroma_v_shift);
if (avctx->codec->id == AV_CODEC_ID_LJPEG &&
(avctx->pix_fmt == AV_PIX_FMT_BGR0
- || s->avctx->pix_fmt == AV_PIX_FMT_BGRA
- || s->avctx->pix_fmt == AV_PIX_FMT_BGR24)) {
+ || avctx->pix_fmt == AV_PIX_FMT_BGRA
+ || avctx->pix_fmt == AV_PIX_FMT_BGR24)) {
vsample[0] = hsample[0] =
vsample[1] = hsample[1] =
vsample[2] = hsample[2] = 1;
@@ -319,9 +317,14 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
put_bits(pb, 8, 0); /* Ah/Al (not used) */
end:
- s->esc_pos = put_bits_count(pb) >> 3;
- for(i=1; i<s->slice_context_count; i++)
- s->thread_context[i]->esc_pos = 0;
+ if (avctx->codec->priv_data_size == sizeof(MpegEncContext)) {
+ MpegEncContext *s = avctx->priv_data;
+ av_assert0(avctx->codec->priv_data_size == sizeof(MpegEncContext));
+
+ s->esc_pos = put_bits_count(pb) >> 3;
+ for(i=1; i<s->slice_context_count; i++)
+ s->thread_context[i]->esc_pos = 0;
+ }
}
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
@@ -530,6 +533,9 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
MpegEncContext *s = avctx->priv_data;
AVFrame pic = *pic_arg;
int i;
+ int chroma_h_shift, chroma_v_shift;
+
+ av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
//CODEC_FLAG_EMU_EDGE have to be cleared
if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)
@@ -537,7 +543,8 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
//picture should be flipped upside-down
for(i=0; i < 3; i++) {
- pic.data[i] += (pic.linesize[i] * (s->mjpeg_vsample[i] * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
+ int vsample = i ? 2 >> chroma_v_shift : 2;
+ pic.data[i] += (pic.linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
pic.linesize[i] *= -1;
}
return ff_MPV_encode_picture(avctx, pkt, &pic, got_packet);