~ubuntu-dev/mplayer/ubuntu-feisty

« back to all changes in this revision

Viewing changes to libavformat/grab.c

  • Committer: William Grant
  • Date: 2007-02-03 03:16:07 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: william.grant@ubuntu.org.au-20070203031607-08gc2ompbz6spt9i
Update to 1.0rc1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Linux video grab interface
3
3
 * Copyright (c) 2000,2001 Fabrice Bellard.
4
4
 *
5
 
 * This library is free software; you can redistribute it and/or
 
5
 * This file is part of FFmpeg.
 
6
 *
 
7
 * FFmpeg is free software; you can redistribute it and/or
6
8
 * modify it under the terms of the GNU Lesser General Public
7
9
 * License as published by the Free Software Foundation; either
8
 
 * version 2 of the License, or (at your option) any later version.
 
10
 * version 2.1 of the License, or (at your option) any later version.
9
11
 *
10
 
 * This library is distributed in the hope that it will be useful,
 
12
 * FFmpeg is distributed in the hope that it will be useful,
11
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
15
 * Lesser General Public License for more details.
14
16
 *
15
17
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library; if not, write to the Free Software
 
18
 * License along with FFmpeg; if not, write to the Free Software
17
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
20
 */
19
21
#include "avformat.h"
62
64
    int width, height;
63
65
    int video_fd, frame_size;
64
66
    int ret, frame_rate, frame_rate_base;
65
 
    int desired_palette;
 
67
    int desired_palette, desired_depth;
66
68
    struct video_tuner tuner;
67
69
    struct video_audio audio;
68
70
    struct video_picture pict;
118
120
    }
119
121
 
120
122
    desired_palette = -1;
121
 
    if (st->codec->pix_fmt == PIX_FMT_YUV420P) {
 
123
    desired_depth = -1;
 
124
    if (ap->pix_fmt == PIX_FMT_YUV420P) {
122
125
        desired_palette = VIDEO_PALETTE_YUV420P;
123
 
    } else if (st->codec->pix_fmt == PIX_FMT_YUV422) {
 
126
        desired_depth = 12;
 
127
    } else if (ap->pix_fmt == PIX_FMT_YUV422) {
124
128
        desired_palette = VIDEO_PALETTE_YUV422;
125
 
    } else if (st->codec->pix_fmt == PIX_FMT_BGR24) {
 
129
        desired_depth = 16;
 
130
    } else if (ap->pix_fmt == PIX_FMT_BGR24) {
126
131
        desired_palette = VIDEO_PALETTE_RGB24;
 
132
        desired_depth = 24;
127
133
    }
128
134
 
129
135
    /* set tv standard */
155
161
#endif
156
162
    /* try to choose a suitable video format */
157
163
    pict.palette = desired_palette;
 
164
    pict.depth= desired_depth;
158
165
    if (desired_palette == -1 || (ret = ioctl(video_fd, VIDIOCSPICT, &pict)) < 0) {
159
166
        pict.palette=VIDEO_PALETTE_YUV420P;
 
167
        pict.depth=12;
160
168
        ret = ioctl(video_fd, VIDIOCSPICT, &pict);
161
169
        if (ret < 0) {
162
170
            pict.palette=VIDEO_PALETTE_YUV422;
 
171
            pict.depth=16;
163
172
            ret = ioctl(video_fd, VIDIOCSPICT, &pict);
164
173
            if (ret < 0) {
165
174
                pict.palette=VIDEO_PALETTE_RGB24;
 
175
                pict.depth=24;
166
176
                ret = ioctl(video_fd, VIDIOCSPICT, &pict);
167
177
                if (ret < 0)
168
 
                    goto fail1;
 
178
                    pict.palette=VIDEO_PALETTE_GREY;
 
179
                    pict.depth=8;
 
180
                    ret = ioctl(video_fd, VIDIOCSPICT, &pict);
 
181
                    if (ret < 0)
 
182
                        goto fail1;
169
183
            }
170
184
        }
171
185
    }
248
262
        frame_size = width * height * 3;
249
263
        st->codec->pix_fmt = PIX_FMT_BGR24; /* NOTE: v4l uses BGR24, not RGB24 ! */
250
264
        break;
 
265
    case VIDEO_PALETTE_GREY:
 
266
        frame_size = width * height * 1;
 
267
        st->codec->pix_fmt = PIX_FMT_GRAY8;
 
268
        break;
251
269
    default:
252
270
        goto fail;
253
271
    }
357
375
    return 0;
358
376
}
359
377
 
360
 
static AVInputFormat video_grab_device_format = {
 
378
AVInputFormat video_grab_device_demuxer = {
361
379
    "video4linux",
362
380
    "video grab",
363
381
    sizeof(VideoData),
840
858
    av_freep(&s->src_mem);
841
859
    return 0;
842
860
}
843
 
 
844
 
int video_grab_init(void)
845
 
{
846
 
    av_register_input_format(&video_grab_device_format);
847
 
    return 0;
848
 
}