]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/v4l2_m2m_enc.c
avcodec/vlc, bitstream: Allow to use BE codes to initialize LE VLC
[ffmpeg] / libavcodec / v4l2_m2m_enc.c
index 56df4286adde5a25163677649f94c6a6effb087f..f644b50133b436e632cd915971e3d9a4dae58ee7 100644 (file)
@@ -295,16 +295,20 @@ static int v4l2_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
     if (s->draining)
         goto dequeue;
 
-    ret = ff_encode_get_frame(avctx, frame);
-    if (ret < 0 && ret != AVERROR_EOF)
-        return ret;
+    if (!frame->buf[0]) {
+        ret = ff_encode_get_frame(avctx, frame);
+        if (ret < 0 && ret != AVERROR_EOF)
+            return ret;
 
-    if (ret == AVERROR_EOF)
-        frame = NULL;
+        if (ret == AVERROR_EOF)
+            frame = NULL;
+    }
 
     ret = v4l2_send_frame(avctx, frame);
-    av_frame_unref(frame);
-    if (ret < 0)
+    if (ret != AVERROR(EAGAIN))
+        av_frame_unref(frame);
+
+    if (ret < 0 && ret != AVERROR(EAGAIN))
         return ret;
 
     if (!output->streamon) {
@@ -429,6 +433,7 @@ static const AVCodecDefault v4l2_m2m_defaults[] = {
         .close          = v4l2_encode_close, \
         .defaults       = v4l2_m2m_defaults, \
         .capabilities   = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \
+        .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP, \
         .wrapper_name   = "v4l2m2m", \
     }