comparison libopenjpeg.c @ 9715:997d2de9cd84 libavcodec

Add lowres support to the libopenjpeg wrapper. Fixes issue 1097.
author jai_menon
date Tue, 26 May 2009 17:04:28 +0000
parents 5df11d49abb7
children 00581e706e1d
comparison
equal deleted inserted replaced
9714:5df11d49abb7 9715:997d2de9cd84
87 av_log(avctx, AV_LOG_ERROR, "Error initializing decoder.\n"); 87 av_log(avctx, AV_LOG_ERROR, "Error initializing decoder.\n");
88 return -1; 88 return -1;
89 } 89 }
90 opj_set_event_mgr((opj_common_ptr)dec, NULL, NULL); 90 opj_set_event_mgr((opj_common_ptr)dec, NULL, NULL);
91 91
92 ctx->dec_params.cp_reduce = avctx->lowres;
92 // Tie decoder with decoding parameters 93 // Tie decoder with decoding parameters
93 opj_setup_decoder(dec, &ctx->dec_params); 94 opj_setup_decoder(dec, &ctx->dec_params);
94 stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size); 95 stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size);
95 if(!stream) { 96 if(!stream) {
96 av_log(avctx, AV_LOG_ERROR, "Codestream could not be opened for reading.\n"); 97 av_log(avctx, AV_LOG_ERROR, "Codestream could not be opened for reading.\n");
104 if(!image) { 105 if(!image) {
105 av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n"); 106 av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n");
106 opj_destroy_decompress(dec); 107 opj_destroy_decompress(dec);
107 return -1; 108 return -1;
108 } 109 }
109 width = image->comps[0].w; 110 width = image->comps[0].w << avctx->lowres;
110 height = image->comps[0].h; 111 height = image->comps[0].h << avctx->lowres;
111 if(avcodec_check_dimensions(avctx, width, height) < 0) { 112 if(avcodec_check_dimensions(avctx, width, height) < 0) {
112 av_log(avctx, AV_LOG_ERROR, "%dx%d dimension invalid.\n", width, height); 113 av_log(avctx, AV_LOG_ERROR, "%dx%d dimension invalid.\n", width, height);
113 goto done; 114 goto done;
114 } 115 }
115 avcodec_set_dimensions(avctx, width, height); 116 avcodec_set_dimensions(avctx, width, height);