diff mbox series

[FFmpeg-devel,1/3] avdevice/lavfi: fix FIXME and check a/v type by codec_type

Message ID 1600391066-15693-1-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit 7786d795c294bd56aeaec5d913bf41dc5e7725c8
Headers show
Series [FFmpeg-devel,1/3] avdevice/lavfi: fix FIXME and check a/v type by codec_type
Related show

Checks

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

Commit Message

Limin Wang Sept. 18, 2020, 1:04 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavdevice/lavfi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Nicolas George Sept. 20, 2020, 3:20 p.m. UTC | #1
lance.lmwang@gmail.com (12020-09-18):
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavdevice/lavfi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

LGTM, thanks.

Regards,
diff mbox series

Patch

diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 4f05a15..268dc0d 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -386,6 +386,7 @@  static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
     AVDictionary *frame_metadata;
     int ret, i;
     int size = 0;
+    AVStream *st;
 
     if (lavfi->subcc_packet.size) {
         av_packet_move_ref(pkt, &lavfi->subcc_packet);
@@ -426,15 +427,16 @@  static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
 
     av_buffersink_get_frame_flags(lavfi->sinks[min_pts_sink_idx], frame, 0);
     stream_idx = lavfi->sink_stream_map[min_pts_sink_idx];
+    st = avctx->streams[stream_idx];
 
-    if (frame->width /* FIXME best way of testing a video */) {
+    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
         size = av_image_get_buffer_size(frame->format, frame->width, frame->height, 1);
         if ((ret = av_new_packet(pkt, size)) < 0)
             return ret;
 
         av_image_copy_to_buffer(pkt->data, size, (const uint8_t **)frame->data, frame->linesize,
                                 frame->format, frame->width, frame->height, 1);
-    } else if (frame->channels /* FIXME test audio */) {
+    } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
         size = frame->nb_samples * av_get_bytes_per_sample(frame->format) *
                                    frame->channels;
         if ((ret = av_new_packet(pkt, size)) < 0)