On Tue, 2010-11-16 at 12:41 +0000, Mark Kenna wrote: > On 16/11/2010 12:34, Tomas Härdin wrote: > > On Tue, 2010-11-16 at 12:28 +0000, Mark Kenna wrote: > >> On 16/11/2010 12:24, sq.cheng wrote: > >>> use the video decode to do it > >>> just like decoding mpeg4 or h.264, with the JPEG codec id(I don't remember > >>> what's name, something like MJPEG) > >>> then decode one frame, it will output one yuv frame, > >>> and it seems I once met the output is yuyv, according to the input image. > >>> > >>> > >>> On Tue, Nov 16, 2010 at 8:11 PM, Mark Kenna< > >>> [email protected]> wrote: > >>> > >>>> Hi Guys > >>>> > >>>> Does anyone know if it's possible to convert a JPEG to YUV frame simply > >>>> using LibAv*? Currently I am converting to a Bitmap and converting the > >>>> RGB > >>>> data to a YUV frame using sws. If there is a simpler (and more efficient) > >>>> method I would love to know about it. > >>>> > >>>> Thanks, > >>>> Mark. > >>>> > >>>> _______________________________________________ > >>>> libav-user mailing list > >>>> [email protected] > >>>> https://lists.mplayerhq.hu/mailman/listinfo/libav-user > >>>> > >>> _______________________________________________ > >>> libav-user mailing list > >>> [email protected] > >>> https://lists.mplayerhq.hu/mailman/listinfo/libav-useriewsystems.com/support > >> Interesting - I will give it a try. If someone could specify the exact > >> codec to use I would appreciate it. > >> > >> Thanks, > >> Mark. > > Use the mjpeg decoder (CODEC_ID_MJPEG). It should work fine. > > > > Also, since jpeg supports a number of YUV formats you might want to make > > sure your input is in the format you want. Otherwise you will have to > > use libswscale anyway. It's probably quite a bit faster converting YUV > > -> YUV than RGB -> YUV though. > > > > /Tomas > > > > > > _______________________________________________ > > libav-user mailing list > > [email protected] > > https://lists.mplayerhq.hu/mailman/listinfo/libav-user > How exactly would one check the input format first? I would write it > like so: > > 1. Check input format, if YUV then just decode > 2. If input format != YUV, decode and then scale it to YUV > 3. Handle YUV > > Does that sound about right? > > Thanks, > Mark.
Sort of. I assume you want normal YUV 4:2:0, aka PIX_FMT_YUV420P.
Inspect AVCodecContext::pix_fmt to figure out whether you need to use
libswscale or not. So:
if(avctx->pix_fmt != PIX_FMT_YUV420P) {
//setup libswscale to convert avctx->pix_fmt to PIX_FMT_YUV420P
}
Then later you just convert the output from the decoder if you need to,
like for instance ffplay and libavformat/output-example.c do.
/Tomas
signature.asc
Description: This is a digitally signed message part
_______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
