diff mbox series

[FFmpeg-devel,v2,1/3] avdevice/xv: add support of wrapped avframe codec

Message ID 20200411182008.11454-1-cus@passwd.hu
State Accepted
Commit e4ce40d25b6368cd4492f5c579e155dfe9639311
Headers show
Series [FFmpeg-devel,v2,1/3] avdevice/xv: add support of wrapped avframe codec | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Marton Balint April 11, 2020, 6:20 p.m. UTC
Also change the default to that.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavdevice/xv.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

Comments

Nicolas George April 14, 2020, 1:32 p.m. UTC | #1
Marton Balint (12020-04-11):
> Also change the default to that.
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavdevice/xv.c | 22 ++++++++++++++--------
>  1 file changed, 14 insertions(+), 8 deletions(-)

No objection. Thanks.

Regards,
Marton Balint April 16, 2020, 10:03 p.m. UTC | #2
On Tue, 14 Apr 2020, Nicolas George wrote:

> Marton Balint (12020-04-11):
>> Also change the default to that.
>>
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>>  libavdevice/xv.c | 22 ++++++++++++++--------
>>  1 file changed, 14 insertions(+), 8 deletions(-)
>
> No objection. Thanks.

Thanks, applied.

Regards,
Marton
diff mbox series

Patch

diff --git a/libavdevice/xv.c b/libavdevice/xv.c
index c3ed2e48bd..50dc4e0d04 100644
--- a/libavdevice/xv.c
+++ b/libavdevice/xv.c
@@ -113,8 +113,8 @@  static int xv_write_header(AVFormatContext *s)
 
     if (   s->nb_streams > 1
         || par->codec_type != AVMEDIA_TYPE_VIDEO
-        || par->codec_id   != AV_CODEC_ID_RAWVIDEO) {
-        av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
+        || (par->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME && par->codec_id != AV_CODEC_ID_RAWVIDEO)) {
+        av_log(s, AV_LOG_ERROR, "Only a single raw or wrapped avframe video stream is supported.\n");
         return AVERROR(EINVAL);
     }
 
@@ -322,12 +322,18 @@  static int write_picture(AVFormatContext *s, uint8_t *input_data[4],
 static int xv_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
     AVCodecParameters *par = s->streams[0]->codecpar;
-    uint8_t *data[4];
-    int linesize[4];
 
-    av_image_fill_arrays(data, linesize, pkt->data, par->format,
-                         par->width, par->height, 1);
-    return write_picture(s, data, linesize);
+    if (par->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME) {
+        AVFrame *frame = (AVFrame *)pkt->data;
+        return write_picture(s, frame->data, frame->linesize);
+    } else {
+        uint8_t *data[4];
+        int linesize[4];
+
+        av_image_fill_arrays(data, linesize, pkt->data, par->format,
+                             par->width, par->height, 1);
+        return write_picture(s, data, linesize);
+    }
 }
 
 static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame,
@@ -375,7 +381,7 @@  AVOutputFormat ff_xv_muxer = {
     .long_name      = NULL_IF_CONFIG_SMALL("XV (XVideo) output device"),
     .priv_data_size = sizeof(XVContext),
     .audio_codec    = AV_CODEC_ID_NONE,
-    .video_codec    = AV_CODEC_ID_RAWVIDEO,
+    .video_codec    = AV_CODEC_ID_WRAPPED_AVFRAME,
     .write_header   = xv_write_header,
     .write_packet   = xv_write_packet,
     .write_uncoded_frame = xv_write_frame,