On Fri, Dec 09, 2011 at 01:14:59PM +0100, Luca Barbato wrote:
> On 09/12/11 11:07, Kostya Shishkov wrote:
> >+static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
> >+ AVPacket *avpkt)
> >+{
> >+ int h, w;
> >+ AVFrame *pic = avctx->coded_frame;
> >+ const uint8_t* src = avpkt->data;
>
> uint8_t *src
Why can't I impose an additional constraints if I feel so?
> >+ uint8_t *Y1, *Y2, *U, *V;
> >+ int ret;
> >+
> >+ if (pic->data[0])
> >+ avctx->release_buffer(avctx, pic);
> >+
> >+ if (avpkt->size< avctx->width * avctx->height * 3 / 2 + 16) {
> >+ av_log(avctx, AV_LOG_ERROR, "packet too small\n");
> >+ return AVERROR_INVALIDDATA;
> >+ }
> >+
> >+ pic->reference = 0;
> >+ if ((ret = avctx->get_buffer(avctx, pic))< 0)
> >+ return ret;
> >+
> >+ pic->pict_type = AV_PICTURE_TYPE_I;
> >+ pic->key_frame = 1;
> >+
> >+ if (AV_RL32(src) != 0x01000002) {
> >+ av_log_ask_for_sample(avctx, "Unknown frame header %X\n",
> >AV_RL32(src));
> >+ return AVERROR_PATCHWELCOME;
> >+ }
> >+ src += 16;
> >+
> >+ Y1 = pic->data[0];
> >+ Y2 = pic->data[0] + pic->linesize[0];
> >+ U = pic->data[1];
> >+ V = pic->data[2];
> >+ for (h = 0; h< avctx->height; h += 2) {
> >+ for (w = 0; w< avctx->width; w += 2) {
> >+ AV_WN16A(Y1 + w, AV_RN16A(src));
> >+ AV_WN16A(Y2 + w, AV_RN16A(src + 2));
> >+ U[w>> 1] = src[4] + 0x80;
> >+ V[w>> 1] = src[5] + 0x80;
> >+ src += 6;
> >+ }
> >+ Y1 += pic->linesize[0]<< 1;
> >+ Y2 += pic->linesize[0]<< 1;
I wonder why it does shift spaces in reply? On patchworkk and and in ML
archive it's correct.
> >+ U += pic->linesize[1];
> >+ V += pic->linesize[2];
> >+ }
> >+
> >+ *data_size = sizeof(AVFrame);
> >+ *(AVFrame*)data = *avctx->coded_frame;
>
> Uhm...
Uhm what? If you mean that it should be *(AVFrame*)data = *pic; then you're
right but it's equivalent anyway.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel