diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2007-09-09 08:42:49 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2007-09-09 08:42:49 +0000 |
commit | 4f8a91c961db17643277305cdf0eabcffdb282a9 (patch) | |
tree | ec9f59cf6c6d502446ef22ce2b8abdcf249ffa8e /libavcodec | |
parent | c612b00d7eb68102fb48ce9b36030b92fb3fa0e8 (diff) | |
download | ffmpeg-4f8a91c961db17643277305cdf0eabcffdb282a9.tar.gz |
First ugly and slow attempt to fix nuv files with extra frameheader
and per-frame rtjpeg quality
Originally committed as revision 10441 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/nuv.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 176fc252f3..665527bbe9 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -30,6 +30,7 @@ typedef struct { AVFrame pic; + int codec_frameheader; int width, height; unsigned int decomp_size; unsigned char* decomp_buf; @@ -38,6 +39,28 @@ typedef struct { DSPContext dsp; } NuvContext; +static const uint8_t fallback_lquant[] = { + 16, 11, 10, 16, 24, 40, 51, 61, + 12, 12, 14, 19, 26, 58, 60, 55, + 14, 13, 16, 24, 40, 57, 69, 56, + 14, 17, 22, 29, 51, 87, 80, 62, + 18, 22, 37, 56, 68, 109, 103, 77, + 24, 35, 55, 64, 81, 104, 113, 92, + 49, 64, 78, 87, 103, 121, 120, 101, + 72, 92, 95, 98, 112, 100, 103, 99 +}; + +static const uint8_t fallback_cquant[] = { + 17, 18, 24, 47, 99, 99, 99, 99, + 18, 21, 26, 66, 99, 99, 99, 99, + 24, 26, 56, 99, 99, 99, 99, 99, + 47, 66, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99 +}; + /** * \brief copy frame data from buffer to AVFrame, handling stride. * \param f destination AVFrame @@ -69,6 +92,17 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c, return 0; } +/** + * \brief set quantization tables from a quality value + */ +static void get_quant_quality(NuvContext *c, int quality) { + int i; + for (i = 0; i < 64; i++) { + c->lq[i] = (fallback_lquant[i] << 7) / quality; + c->cq[i] = (fallback_cquant[i] << 7) / quality; + } +} + static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { NuvContext *c = avctx->priv_data; @@ -121,6 +155,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, buf = c->decomp_buf; buf_size = c->decomp_size; } + if (c->codec_frameheader) { + get_quant_quality(c, buf[10]); + rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq); + buf = &buf[12]; + buf_size -= 12; + } c->pic.pict_type = FF_I_TYPE; c->pic.key_frame = 1; @@ -172,6 +212,7 @@ static int decode_init(AVCodecContext *avctx) { } avctx->pix_fmt = PIX_FMT_YUV420P; c->pic.data[0] = NULL; + c->codec_frameheader = avctx->codec_tag == MKTAG('R', 'J', 'P', 'G'); c->width = avctx->width; c->height = avctx->height; c->decomp_size = c->height * c->width * 3 / 2; |