comparison mjpegdec.c @ 10539:8d8fcc20dd30 libavcodec

Disable image flipping during JPEG decoding if CODEC_FLAG_EMU_EDGE is set instead of either aborting on the assert or crashing due to writing beyond the array due to insufficient padding.
author reimar
date Thu, 19 Nov 2009 11:49:03 +0000
parents 3e404d2520a7
children 981e7720fc03
comparison
equal deleted inserted replaced
10538:89527d128fc9 10539:8d8fcc20dd30
768 static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, int Al){ 768 static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, int Al){
769 int i, mb_x, mb_y; 769 int i, mb_x, mb_y;
770 uint8_t* data[MAX_COMPONENTS]; 770 uint8_t* data[MAX_COMPONENTS];
771 int linesize[MAX_COMPONENTS]; 771 int linesize[MAX_COMPONENTS];
772 772
773 if(s->flipped && s->avctx->flags & CODEC_FLAG_EMU_EDGE) {
774 av_log(s->avctx, AV_LOG_ERROR, "Can not flip image with CODEC_FLAG_EMU_EDGE set!\n");
775 s->flipped = 0;
776 }
773 for(i=0; i < nb_components; i++) { 777 for(i=0; i < nb_components; i++) {
774 int c = s->comp_index[i]; 778 int c = s->comp_index[i];
775 data[c] = s->picture.data[c]; 779 data[c] = s->picture.data[c];
776 linesize[c]=s->linesize[c]; 780 linesize[c]=s->linesize[c];
777 s->coefs_finished[c] |= 1; 781 s->coefs_finished[c] |= 1;
778 if(s->flipped) { 782 if(s->flipped) {
779 //picture should be flipped upside-down for this codec 783 //picture should be flipped upside-down for this codec
780 assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE));
781 data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 )); 784 data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 ));
782 linesize[c] *= -1; 785 linesize[c] *= -1;
783 } 786 }
784 } 787 }
785 788