On Wed, Feb 04, 2015 at 02:21:28PM +0000, Vittorio Giovara wrote:
> Based on work by Kostya Shishkov <[email protected]>.
> ---
> Changelog | 1 +
> libavcodec/Makefile | 1 +
> libavcodec/allcodecs.c | 1 +
> libavcodec/avcodec.h | 1 +
> libavcodec/codec_desc.c | 7 +
> libavcodec/hqx.c | 639 ++++++++++++
> libavcodec/hqxvlc.c | 2182
> ++++++++++++++++++++++++++++++++++++++++
> libavcodec/hqxvlc.h | 55 +
> libavcodec/version.h | 2 +-
> libavformat/riff.c | 1 +
> tests/fate/video.mak | 9 +
> tests/ref/fate/canopus-hqx422 | 2 +
> tests/ref/fate/canopus-hqx422a | 2 +
> 13 files changed, 2902 insertions(+), 1 deletion(-)
> create mode 100644 libavcodec/hqx.c
> create mode 100644 libavcodec/hqxvlc.c
> create mode 100644 libavcodec/hqxvlc.h
> create mode 100644 tests/ref/fate/canopus-hqx422
> create mode 100644 tests/ref/fate/canopus-hqx422a
docs update
> --- /dev/null
> +++ b/libavcodec/hqx.c
> @@ -0,0 +1,639 @@
> +
> +#include "get_bits.h"
> +#include "avcodec.h"
> +#include "internal.h"
nit: order
> +typedef struct HQXContext {
> + AVCodecContext *avctx;
Why do you need a full AVCodecContext here?
> +static void hqx_idct_put(uint16_t *dst, int stride, int16_t *block,
> + const uint8_t *quant)
ptrdiff_t stride?
> + int i, j, v;
> +
> + hqx_idct(block, quant);
> +
> + for (i = 0; i < 8; i++) {
> + for (j = 0; j < 8; j++) {
> + v = av_clip(block[j + i * 8] + 0x800, 0, 0x1000);
> + dst[j] = (v << 4) | (v >> 8);
> + }
> + dst += stride >> 1;
> + }
v could have a smaller scope.
> +static inline void put_blocks(AVFrame *pic, int plane,
> + int x, int y, int ilace,
> + int16_t *block0, int16_t *block1,
> + const uint8_t *quant)
> +{
> + if (!ilace) {
> + hqx_idct_put(
> + (uint16_t *)(pic->data[plane] + x * 2 + y *
> pic->linesize[plane]),
> + pic->linesize[plane], block0, quant);
> + hqx_idct_put(
> + (uint16_t *)(pic->data[plane] + x * 2 + (y + 8) *
> pic->linesize[plane]),
> + pic->linesize[plane], block1, quant);
> + } else {
> + hqx_idct_put(
> + (uint16_t *)(pic->data[plane] + x * 2 + y *
> pic->linesize[plane]),
> + pic->linesize[plane] * 2, block0, quant);
> + hqx_idct_put(
> + (uint16_t *)(pic->data[plane] + x * 2 + (y + 1) *
> pic->linesize[plane]),
> + pic->linesize[plane] * 2, block1, quant);
> + }
> +}
How about
int fields = ilace ? 2 : 1;
hqx_idct_put((uint16_t *)(pic->data[plane] + x * 2 + y *
pic->linesize[plane]),
pic->linesize[plane] * fields, block0, quant);
hqx_idct_put((uint16_t *)(pic->data[plane] + x * 2 + (y + 1) *
pic->linesize[plane]),
pic->linesize[plane] * fields, block1, quant);
or similar ..
> +static int decode_block(GetBitContext *gb, const int *quants, int dcb,
> + int16_t block[64], int *last_dc)
> +{
> +
> + memset(block, 0, 64 * sizeof(*block));
FF_ARRAY_ELEMS(block) * sizeof(*block)
sizeof(block)
> + *last_dc = *last_dc + dc;
+=
> +static int hqx_decode_422a(HQXContext *ctx, AVFrame *pic,
> + GetBitContext *gb, int x, int y)
> +{
> + const int *quants;
> + int flag = 0;
> + int last_dc;
> + int i, ret;
> + int cbp;
> +
> + cbp = get_vlc2(gb, ff_hqx_cbp_vlc.table, ff_hqx_cbp_vlc.bits, 1);
> +
> + for (i = 0; i < 12; i++)
> + memset(ctx->block[i], 0, sizeof(**ctx->block) * 64);
FF_ARRAY_ELEMS(ctx->block[i]) * sizeof(*ctx->block[i])
sizeof(ctx->block[i])
> +static int hqx_decode_444a(HQXContext *ctx, AVFrame *pic,
> + GetBitContext *gb, int x, int y)
> +{
> +
> + for (i = 0; i < 16; i++)
> + memset(ctx->block[i], 0, sizeof(**ctx->block) * 64);
same
> +static int hqx_decode_frame(AVCodecContext *avctx, void *data,
> + int *got_picture_ptr, AVPacket *avpkt)
> +{
> + if (src[0] != 'H' || src[1] != 'Q') {
> + av_log(avctx, AV_LOG_ERROR, "Not a HQX frame.\n");
Not an
> --- /dev/null
> +++ b/libavcodec/hqxvlc.c
> @@ -0,0 +1,2182 @@
> +
> +void ff_hqx_init_vlcs(void)
av_cold
> --- /dev/null
> +++ b/libavcodec/hqxvlc.h
> @@ -0,0 +1,55 @@
> +
> +#ifndef AVCODEC_HQXVLC_H
> +#define AVCODEC_HQXVLC_H
> +
> +#include "get_bits.h"
stdint.h is enough.
> --- a/tests/fate/video.mak
> +++ b/tests/fate/video.mak
> @@ -55,6 +55,15 @@ fate-bmv-video: CMD = framecrc -i
> $(TARGET_SAMPLES)/bmv/SURFING-partial.BMV -pix
> FATE_SAMPLES_AVCONV-$(call DEMDEC, MPEGPS, CAVS) += fate-cavs
> fate-cavs: CMD = framecrc -i $(TARGET_SAMPLES)/cavs/cavs.mpg -an
>
> +FATE_CANOPUS_HQX += fate-canopus-hqx422
> +fate-canopus-hqx422: CMD = framecrc -i $(TARGET_SAMPLES)/canopus/hqx422.avi
> -an
order
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel