summaryrefslogtreecommitdiff
path: root/libavcodec/rtjpeg.c
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2014-01-29 18:04:55 +0100
committerDiego Biurrun <diego@biurrun.de>2014-03-22 06:17:29 -0700
commit1df0b061621b10edde87e3ab7ea83aed381c574f (patch)
tree384f82fbd80482a233f832219a9399d5d8ecc29e /libavcodec/rtjpeg.c
parent46caba4a65237c006ab54b0c16ecc00d21dedda1 (diff)
nuv: Reuse the DSPContext from RTJpegContext
There is no point in populating NuvContext with another DSPContext. Also split static and dynamic initialization bits to avoid running the static initialization parts over and over.
Diffstat (limited to 'libavcodec/rtjpeg.c')
-rw-r--r--libavcodec/rtjpeg.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/libavcodec/rtjpeg.c b/libavcodec/rtjpeg.c
index f5abe637f3..3188e6f6aa 100644
--- a/libavcodec/rtjpeg.c
+++ b/libavcodec/rtjpeg.c
@@ -121,7 +121,7 @@ int ff_rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f,
if (res < 0) \
return res; \
if (res > 0) \
- c->dsp->idct_put(dst, stride, block); \
+ c->dsp.idct_put(dst, stride, block); \
} while (0)
int16_t *block = c->block;
BLOCK(c->lquant, y1, f->linesize[0]);
@@ -148,7 +148,6 @@ int ff_rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f,
/**
* @brief initialize an RTJpegContext, may be called multiple times
* @param c context to initialize
- * @param dsp specifies the idct to use for decoding
* @param width width of image, will be rounded down to the nearest multiple
* of 16 for decoding
* @param height height of image, will be rounded down to the nearest multiple
@@ -156,21 +155,29 @@ int ff_rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f,
* @param lquant luma quantization table to use
* @param cquant chroma quantization table to use
*/
-void ff_rtjpeg_decode_init(RTJpegContext *c, DSPContext *dsp,
- int width, int height,
+void ff_rtjpeg_decode_init(RTJpegContext *c, int width, int height,
const uint32_t *lquant, const uint32_t *cquant) {
int i;
- c->dsp = dsp;
for (i = 0; i < 64; i++) {
- int z = ff_zigzag_direct[i];
- int p = c->dsp->idct_permutation[i];
- z = ((z << 3) | (z >> 3)) & 63; // rtjpeg uses a transposed variant
-
- // permute the scan and quantization tables for the chosen idct
- c->scan[i] = c->dsp->idct_permutation[z];
+ int p = c->dsp.idct_permutation[i];
c->lquant[p] = lquant[i];
c->cquant[p] = cquant[i];
}
c->w = width;
c->h = height;
}
+
+void ff_rtjpeg_init(RTJpegContext *c, AVCodecContext *avctx)
+{
+ int i;
+
+ ff_dsputil_init(&c->dsp, avctx);
+
+ for (i = 0; i < 64; i++) {
+ int z = ff_zigzag_direct[i];
+ z = ((z << 3) | (z >> 3)) & 63; // rtjpeg uses a transposed variant
+
+ // permute the scan and quantization tables for the chosen idct
+ c->scan[i] = c->dsp.idct_permutation[z];
+ }
+}