On Mon, Nov 28, 2011 at 12:56 AM, Thad Ward <[email protected]> wrote:
> The attached patch adds support for lagarith's FRAME_ARITH_RGB24 frame type.
> As the decoding method is mostly identical to the RGBA frame type, I made
Nice :)
> that code path handle both.
> Also, how does one get samples added to the fate test sample set? I've been
> creating tests for lagarith's various frame types.
That's good to hear. I have almost no samples it will be nice to have
some regression tests. Do you have any 4:2:2 or 4:4:4 samples?
> diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c
> index 1aa9ec3..0595d57 100644
> --- a/libavcodec/lagarith.c
> +++ b/libavcodec/lagarith.c
> @@ -447,7 +447,7 @@ static int lag_decode_frame(AVCodecContext *avctx,
> uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9;
> int offs[4];
> uint8_t *srcs[4], *dst;
> - int i, j;
> + int i, j, planes;
Initialize planes to 3.
> AVFrame *picture = data;
>
> @@ -479,7 +479,17 @@ static int lag_decode_frame(AVCodecContext *avctx,
> }
> break;
> case FRAME_ARITH_RGBA:
> - avctx->pix_fmt = PIX_FMT_RGB32;
> + case FRAME_ARITH_RGB24:
> + if (FRAME_ARITH_RGB24 == frametype) {
> + avctx->pix_fmt = PIX_FMT_RGB24;
> + planes = 3;
> + offs[2] = 9;
> + } else if(FRAME_ARITH_RGBA == frametype) {
> + avctx->pix_fmt = PIX_FMT_RGB32;
> + planes = 4;
> + offs[2] = 13;
> + offs[3] = AV_RL32(buf + 9);
> + }
Once you start with planes = 3, you can simplify these branches by
setting planes = 4, incrementing offset_ry by 4 and correctly setting
offs[3] only in the RGBA case. Also, what Kostya said about ordering
of conditions and spacing here, and below.
> if (avctx->get_buffer(avctx, p) < 0) {
> av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
> @@ -487,26 +497,24 @@ static int lag_decode_frame(AVCodecContext *avctx,
> }
> offs[0] = offset_bv;
> offs[1] = offset_gu;
> - offs[2] = 13;
You will also need to set offs[2] equal to offset_ry here.
The rest looks good.
--
-Nathan Caldwell
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel