Hello,

I'm implementing support for hardware video decoder on DM365 and I have some problems with buffers. I have simple testing application with following code (simplified)

...
avformat_open_input(&fctx, filename, NULL, NULL);
...
av_find_stream_info(fctx);
...
codec = avcodec_find_decoder_by_name("libdm365_h264");
...
ret = avcodec_open(avctx, codec)
...
picture = avcodec_alloc_frame();
...
for (i = 0; i < 500; i++) {
    int nb;
    char fname[32];

    if (av_read_frame(fctx, &pkt) < 0)
        break;

    nb = avcodec_decode_video2(avctx, picture, &got_pic, &pkt);
    if (nb < 0) {
        av_log(avctx, AV_LOG_ERROR, "error in decoding\n");
        goto decode_cleanup;
    }
    printf("Decoded frame: %d\n", i);
    sprintf(fname, "frame%02d.jpg", i);
save_image(picture, avctx->pix_fmt, avctx->width, avctx->height, fname);
}

The problem is that the decoder needs to have both input and output data in a buffer which is continuous in physical memory. I can fulfill this constraint for the output data (AVFrame *picture) because the buffer is allocated by codec itself so I can use my own allocator there. Unfortunately I do not know how to handle data of AVPacktet pkt, which are filled in by av_read_frame() - these are allocated by av_malloc which fallbacks to malloc and the buffers probably won't be continuous.

I see two solutions here, but I'm not happy with neither of them:
- copy the whole packet to the continuous buffer (but this will significantly slower the application) - provide own av_malloc wrapper that will use my own allocator (many things from libav* internals will be also allocated there and this is not exactly what I want)


Do please someone know some more elegant solution?

with best regards
Jan

--
Tato zpráva byla vytvořena převratným poštovním klientem Opery: http://www.opera.com/mail/
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to