How do I rotate yuv/rgb image using libav

1.2k views Asked by At

I want to rotate an image I just decoded using libav h.264 decoder.

I see that ffmpeg has this option -vf transpose to do it. but I want to do it programatically. I see that there is a vf_transpose.c in libavfilter which looks like does the same thing.

I want to know how I can exercise it in my code?

EDIT:

Here is the sample code I use to do the decoding::

AVCodec *decHd;
AVCodecContext *ctxDecode = NULL;
AVFrame *pictureDecoded;
AVPacket avPkt;

/* --------
    setup
   -------- */

    avcodec_init();

    /* register all the codecs */
    avcodec_register_all();
    decHd = avcodec_find_decoder(CODEC_ID_H264);

    ctxDecode= avcodec_alloc_context();

    avcodec_get_context_defaults(ctxDecode);
    ctxDecode->flags2 |= CODEC_FLAG2_FAST;
    ctxDecode->pix_fmt = PIX_FMT_YUV420P;
    ctxDecode->width = CAP_WIDTH;
    ctxDecode->height = CAP_HEIGHT;

    if (avcodec_open(ctxDecode, decHd) < 0) 
    {
        printf("avcodec: could not open h.264 decoder\n");
        exit(1);
    }

    pictureDecoded= avcodec_alloc_frame();
    avcodec_get_frame_defaults(pictureDecoded);

/* --------
   decode
   -------- */

    avPkt.size = encOutLen;
    avPkt.data = nals[0].p_payload;
    len = avcodec_decode_video2(ctxDecode, pictureDecoded, &got_picture, &avPkt);

    len = avpicture_layout((AVPicture *)pictureDecoded, ctxDecode->pix_fmt
            , CAP_WIDTH, CAP_HEIGHT, decoderOut, PIC_SIZE);
0

There are 0 answers