aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-12-16 14:42:31 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-12-16 15:05:31 +0100
commit633ae5a2101cf6a4367f89041f6356ebc795f369 (patch)
treece6be8a8bbddd54c36ec27745e2f5a0460c59400 /libavcodec
parent5be38f9421da8a50502e8021191fa180193765ec (diff)
downloadffmpeg-633ae5a2101cf6a4367f89041f6356ebc795f369.tar.gz
mjpegenc: fix 444 block count so it is below 10
Fixes Ticket1990 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mjpegenc.c34
-rw-r--r--libavcodec/mpegvideo_enc.c3
2 files changed, 24 insertions, 13 deletions
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 381f0fb626..b476bcd232 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -137,7 +137,7 @@ static void jpeg_table_header(MpegEncContext *s)
if(s->avctx->active_thread_type & FF_THREAD_SLICE){
put_marker(p, DRI);
put_bits(p, 16, 4);
- put_bits(p, 16, s->mb_width);
+ put_bits(p, 16, s->mb_width*2/s->mjpeg_hsample[0]);
}
/* huffman table */
@@ -458,23 +458,31 @@ static void encode_block(MpegEncContext *s, DCTELEM *block, int n)
void ff_mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64])
{
int i;
- for(i=0;i<5;i++) {
- encode_block(s, block[i], i);
- }
- if (s->chroma_format == CHROMA_420) {
- encode_block(s, block[5], 5);
- } else if (s->chroma_format == CHROMA_422) {
- encode_block(s, block[6], 6);
+ if (s->chroma_format == CHROMA_444) {
+ encode_block(s, block[0], 0);
+ encode_block(s, block[2], 2);
+ encode_block(s, block[4], 4);
+ encode_block(s, block[8], 8);
encode_block(s, block[5], 5);
- encode_block(s, block[7], 7);
- } else {
+ encode_block(s, block[9], 9);
+
+ encode_block(s, block[1], 1);
+ encode_block(s, block[3], 3);
encode_block(s, block[6], 6);
- encode_block(s, block[8], 8);
encode_block(s, block[10], 10);
- encode_block(s, block[5], 5);
encode_block(s, block[7], 7);
- encode_block(s, block[9], 9);
encode_block(s, block[11], 11);
+ } else {
+ for(i=0;i<5;i++) {
+ encode_block(s, block[i], i);
+ }
+ if (s->chroma_format == CHROMA_420) {
+ encode_block(s, block[5], 5);
+ } else {
+ encode_block(s, block[6], 6);
+ encode_block(s, block[5], 5);
+ encode_block(s, block[7], 7);
+ }
}
s->i_tex_bits += get_bits_diff(s);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 08dcf9e793..aff12c6f8e 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -751,6 +751,9 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
s->mjpeg_vsample[0] = s->mjpeg_hsample[0] =
s->mjpeg_vsample[1] = s->mjpeg_hsample[1] =
s->mjpeg_vsample[2] = s->mjpeg_hsample[2] = 1;
+ } else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P || avctx->pix_fmt == AV_PIX_FMT_YUVJ444P) {
+ s->mjpeg_vsample[0] = s->mjpeg_vsample[1] = s->mjpeg_vsample[2] = 2;
+ s->mjpeg_hsample[0] = s->mjpeg_hsample[1] = s->mjpeg_hsample[2] = 1;
} else {
s->mjpeg_vsample[0] = 2;
s->mjpeg_vsample[1] = 2 >> chroma_v_shift;