summaryrefslogtreecommitdiff
authorLukasz Marek <lukasz.m.luki@gmail.com>2013-10-27 20:41:27 (GMT)
committer Lukasz Marek <lukasz.m.luki@gmail.com>2013-10-27 20:45:32 (GMT)
commitb04af34600d01502ac844551d157d83f7ae5db26 (patch)
tree012d02055a3d0ecc1cedc911a550c92b98344287
parent7f5e75eea94020aaddeda1960186ceee73ca1c36 (diff)
downloadffmpeg-b04af34600d01502ac844551d157d83f7ae5db26.zip
ffmpeg-b04af34600d01502ac844551d157d83f7ae5db26.tar.gz
ffmpeg-b04af34600d01502ac844551d157d83f7ae5db26.tar.bz2
lavd/fbdev_enc: more stream validation restrictive
So far fbdev_enc device picked up first video stream and ignored others. It is required to provide exactly one video stream now. Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Diffstat
-rw-r--r--libavdevice/fbdev_enc.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/libavdevice/fbdev_enc.c b/libavdevice/fbdev_enc.c
index c3f8588..9016402 100644
--- a/libavdevice/fbdev_enc.c
+++ b/libavdevice/fbdev_enc.c
@@ -37,7 +37,6 @@ typedef struct {
struct fb_var_screeninfo varinfo; ///< framebuffer variable info
struct fb_fix_screeninfo fixinfo; ///< framebuffer fixed info
int fd; ///< framebuffer device file descriptor
- int index; ///< index of a video stream
uint8_t *data; ///< framebuffer data
} FBDevContext;
@@ -49,21 +48,11 @@ static av_cold int fbdev_write_header(AVFormatContext *h)
int ret, flags = O_RDWR;
int i;
- for (i = 0; i < h->nb_streams; i++) {
- if (h->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- if (!st) {
- fbdev->index = i;
- st = h->streams[i];
- } else {
- av_log(h, AV_LOG_WARNING, "More than one video stream found. First one is used.\n");
- break;
- }
- }
- }
- if (!st) {
- av_log(h, AV_LOG_ERROR, "No video stream found.\n");
+ if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO) {
+ av_log(fbdev, AV_LOG_ERROR, "Only a single video stream is supported.\n");
return AVERROR(EINVAL);
}
+ st = h->streams[0];
if ((fbdev->fd = avpriv_open(h->filename, flags)) == -1) {
ret = AVERROR(errno);
@@ -112,7 +101,7 @@ static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
enum AVPixelFormat fb_pix_fmt;
int disp_height;
int bytes_to_copy;
- AVCodecContext *codec_ctx = h->streams[fbdev->index]->codec;
+ AVCodecContext *codec_ctx = h->streams[0]->codec;
enum AVPixelFormat video_pix_fmt = codec_ctx->pix_fmt;
int video_width = codec_ctx->width;
int video_height = codec_ctx->height;
@@ -120,9 +109,6 @@ static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
int src_line_size = video_width * bytes_per_pixel;
int i;
- if (fbdev->index != pkt->stream_index)
- return 0;
-
if (ioctl(fbdev->fd, FBIOGET_VSCREENINFO, &fbdev->varinfo) < 0)
av_log(h, AV_LOG_WARNING,
"Error refreshing variable info: %s\n", av_err2str(AVERROR(errno)));