#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "avcodec.h"
+#include "copy_block.h"
#include "dsputil.h"
#include "internal.h"
#include "mjpeg.h"
if (s->v_max == 1 && s->h_max == 1 && s->lossless==1 && nb_components==3)
s->rgb = 1;
+ else if (!s->lossless)
+ s->rgb = 0;
/* if different size, realloc/alloc picture */
if ( width != s->width || height != s->height
- || memcmp(s->h_count, h_count, sizeof(h_count[0])*nb_components)
- || memcmp(s->v_count, v_count, sizeof(v_count[0])*nb_components)) {
+ || memcmp(s->h_count, h_count, sizeof(h_count))
+ || memcmp(s->v_count, v_count, sizeof(v_count))) {
av_freep(&s->qscale_table);
s->width = width;
return 0;
}
-static av_always_inline void mjpeg_copy_block(uint8_t *dst, const uint8_t *src,
+static av_always_inline void mjpeg_copy_block(MJpegDecodeContext *s,
+ uint8_t *dst, const uint8_t *src,
int linesize, int lowres)
{
switch (lowres) {
- case 0: copy_block8(dst, src, linesize, linesize, 8);
+ case 0: s->dsp.put_pixels_tab[1][0](dst, src, linesize, 8);
break;
case 1: copy_block4(dst, src, linesize, linesize, 4);
break;
ptr = data[c] + block_offset;
if (!s->progressive) {
if (copy_mb)
- mjpeg_copy_block(ptr, reference_data[c] + block_offset,
+ mjpeg_copy_block(s, ptr, reference_data[c] + block_offset,
linesize[c], s->avctx->lowres);
+
else {
s->dsp.clear_block(s->block);
if (decode_block(s, s->block, i,
if (s->bottom_field == !s->interlace_polarity)
break;
}
- *picture = *s->picture_ptr;
- *got_frame = 1;
- s->got_picture = 0;
-
- if (!s->lossless) {
- picture->quality = FFMAX3(s->qscale[0],
- s->qscale[1],
- s->qscale[2]);
- picture->qstride = 0;
- picture->qscale_table = s->qscale_table;
- memset(picture->qscale_table, picture->quality,
- (s->width + 15) / 16);
- if (avctx->debug & FF_DEBUG_QP)
- av_log(avctx, AV_LOG_DEBUG,
- "QP: %d\n", picture->quality);
- picture->quality *= FF_QP2LAMBDA;
- }
+ *picture = *s->picture_ptr;
+ *got_frame = 1;
+ s->got_picture = 0;
+
+ if (!s->lossless) {
+ picture->quality = FFMAX3(s->qscale[0],
+ s->qscale[1],
+ s->qscale[2]);
+ picture->qstride = 0;
+ picture->qscale_table = s->qscale_table;
+ memset(picture->qscale_table, picture->quality,
+ (s->width + 15) / 16);
+ if (avctx->debug & FF_DEBUG_QP)
+ av_log(avctx, AV_LOG_DEBUG,
+ "QP: %d\n", picture->quality);
+ picture->quality *= FF_QP2LAMBDA;
+ }
goto the_end;
case SOS: