summaryrefslogtreecommitdiff
path: root/libavcodec/ljpegenc.c
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <cehoyos@ag.or.at>2012-02-09 23:26:28 +0100
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2012-02-09 23:26:28 +0100
commit52719dae8a45cec2eb2851b1c14da978e8885e94 (patch)
tree7f56dffb2af561ccd7322da11e0efe618a2db72b /libavcodec/ljpegenc.c
parentedf34c346ec9d5d1a790db4b500113bf8d5fac07 (diff)
Support encoding BGR24 and BGR0 in ljpeg.
Diffstat (limited to 'libavcodec/ljpegenc.c')
-rw-r--r--libavcodec/ljpegenc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index f8178d5adb..4d81b5fc90 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -56,7 +56,9 @@ static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, in
s->header_bits= put_bits_count(&s->pb);
- if(avctx->pix_fmt == PIX_FMT_BGRA){
+ if(avctx->pix_fmt == PIX_FMT_BGR0
+ || avctx->pix_fmt == PIX_FMT_BGRA
+ || avctx->pix_fmt == PIX_FMT_BGR24){
int x, y, i;
const int linesize= p->linesize[0];
uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;
@@ -79,9 +81,15 @@ static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, in
top[i]= left[i]= topleft[i]= buffer[0][i];
}
for(x = 0; x < width; x++) {
+ if(avctx->pix_fmt == PIX_FMT_BGR24){
+ buffer[x][1] = ptr[3*x+0] - ptr[3*x+1] + 0x100;
+ buffer[x][2] = ptr[3*x+2] - ptr[3*x+1] + 0x100;
+ buffer[x][0] = (ptr[3*x+0] + 2*ptr[3*x+1] + ptr[3*x+2])>>2;
+ }else{
buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100;
buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100;
buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2;
+ }
for(i=0;i<3;i++) {
int pred, diff;