Statistics
| Branch: | Revision:

ffmpeg / libavformat / grab.c @ 57060f89

History | View | Annotate | Download (28 KB)

1 de6d9b64 Fabrice Bellard
/*
2
 * Linux video grab interface
3 19720f15 Fabrice Bellard
 * Copyright (c) 2000,2001 Fabrice Bellard.
4 de6d9b64 Fabrice Bellard
 *
5 19720f15 Fabrice Bellard
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2 of the License, or (at your option) any later version.
9 de6d9b64 Fabrice Bellard
 *
10 19720f15 Fabrice Bellard
 * This library is distributed in the hope that it will be useful,
11 de6d9b64 Fabrice Bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 19720f15 Fabrice Bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14 de6d9b64 Fabrice Bellard
 *
15 19720f15 Fabrice Bellard
 * 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
17 5509bffa Diego Biurrun
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 de6d9b64 Fabrice Bellard
 */
19 8be1c656 Fabrice Bellard
#include "avformat.h"
20 de6d9b64 Fabrice Bellard
#include <unistd.h>
21
#include <fcntl.h>
22
#include <sys/ioctl.h>
23
#include <sys/mman.h>
24
#include <sys/time.h>
25 72a476c1 Michael Niedermayer
#define _LINUX_TIME_H 1
26
#include <linux/videodev.h>
27 608d0dee Zdenek Kabelac
#include <time.h>
28 de6d9b64 Fabrice Bellard
29
typedef struct {
30
    int fd;
31
    int frame_format; /* see VIDEO_PALETTE_xxx */
32
    int use_mmap;
33
    int width, height;
34 4972b26f Fabrice Bellard
    int frame_rate;
35 14bea432 Michael Niedermayer
    int frame_rate_base;
36 0c1a9eda Zdenek Kabelac
    int64_t time_frame;
37 4972b26f Fabrice Bellard
    int frame_size;
38 8949367e Fabrice Bellard
    struct video_capability video_cap;
39
    struct video_audio audio_saved;
40 0c1a9eda Zdenek Kabelac
    uint8_t *video_buf;
41 8949367e Fabrice Bellard
    struct video_mbuf gb_buffers;
42
    struct video_mmap gb_buf;
43
    int gb_frame;
44
45
    /* ATI All In Wonder specific stuff */
46
    /* XXX: remove and merge in libavcodec/imgconvert.c */
47
    int aiw_enabled;
48
    int deint;
49
    int halfw;
50 0c1a9eda Zdenek Kabelac
    uint8_t *src_mem;
51
    uint8_t *lum_m4_mem;
52 de6d9b64 Fabrice Bellard
} VideoData;
53
54 8949367e Fabrice Bellard
static int aiw_init(VideoData *s);
55
static int aiw_read_picture(VideoData *s, uint8_t *data);
56
static int aiw_close(VideoData *s);
57 de6d9b64 Fabrice Bellard
58 4972b26f Fabrice Bellard
static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
59 de6d9b64 Fabrice Bellard
{
60 c9a65ca8 Fabrice Bellard
    VideoData *s = s1->priv_data;
61 4972b26f Fabrice Bellard
    AVStream *st;
62 de6d9b64 Fabrice Bellard
    int width, height;
63
    int video_fd, frame_size;
64 14bea432 Michael Niedermayer
    int ret, frame_rate, frame_rate_base;
65 76a77ff2 Luca Abeni
    int desired_palette, desired_depth;
66 e3ee3283 Alex Beregszaszi
    struct video_tuner tuner;
67 8949367e Fabrice Bellard
    struct video_audio audio;
68 c787ba85 Flavio Pimentel Duarte
    struct video_picture pict;
69 7f172339 Fabrice Bellard
    const char *video_device;
70 7aae3168 Michael Niedermayer
    int j;
71 4972b26f Fabrice Bellard
72 11b9c0f4 Luca Abeni
    if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
73
        av_log(s1, AV_LOG_ERROR, "Bad capture size (%dx%d) or wrong time base (%d)\n",
74
            ap->width, ap->height, ap->time_base.den);
75
76 4972b26f Fabrice Bellard
        return -1;
77 11b9c0f4 Luca Abeni
    }
78 115329f1 Diego Biurrun
79 4972b26f Fabrice Bellard
    width = ap->width;
80
    height = ap->height;
81 c0df9d75 Michael Niedermayer
    frame_rate      = ap->time_base.den;
82
    frame_rate_base = ap->time_base.num;
83 4972b26f Fabrice Bellard
84 11b9c0f4 Luca Abeni
    if((unsigned)width > 32767 || (unsigned)height > 32767) {
85
        av_log(s1, AV_LOG_ERROR, "Capture size is out of range: %dx%d\n",
86
            width, height);
87
88 568e18b1 Michael Niedermayer
        return -1;
89 11b9c0f4 Luca Abeni
    }
90 115329f1 Diego Biurrun
91 c9a65ca8 Fabrice Bellard
    st = av_new_stream(s1, 0);
92
    if (!st)
93 4972b26f Fabrice Bellard
        return -ENOMEM;
94 0a7b514f Luca Abeni
    av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
95 4972b26f Fabrice Bellard
96
    s->width = width;
97
    s->height = height;
98 14bea432 Michael Niedermayer
    s->frame_rate      = frame_rate;
99
    s->frame_rate_base = frame_rate_base;
100 de6d9b64 Fabrice Bellard
101 7f172339 Fabrice Bellard
    video_device = ap->device;
102
    if (!video_device)
103
        video_device = "/dev/video";
104 8aa3ee32 Max Krasnyansky
    video_fd = open(video_device, O_RDWR);
105 de6d9b64 Fabrice Bellard
    if (video_fd < 0) {
106 8aa3ee32 Max Krasnyansky
        perror(video_device);
107 4972b26f Fabrice Bellard
        goto fail;
108 de6d9b64 Fabrice Bellard
    }
109 115329f1 Diego Biurrun
110 8949367e Fabrice Bellard
    if (ioctl(video_fd,VIDIOCGCAP, &s->video_cap) < 0) {
111 de6d9b64 Fabrice Bellard
        perror("VIDIOCGCAP");
112
        goto fail;
113
    }
114
115 8949367e Fabrice Bellard
    if (!(s->video_cap.type & VID_TYPE_CAPTURE)) {
116 bb270c08 Diego Biurrun
        av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not handle capture\n");
117 de6d9b64 Fabrice Bellard
        goto fail;
118
    }
119 4606ac8d Zdenek Kabelac
120
    desired_palette = -1;
121 76a77ff2 Luca Abeni
    desired_depth = -1;
122
    if (ap->pix_fmt == PIX_FMT_YUV420P) {
123 4606ac8d Zdenek Kabelac
        desired_palette = VIDEO_PALETTE_YUV420P;
124 76a77ff2 Luca Abeni
        desired_depth = 12;
125
    } else if (ap->pix_fmt == PIX_FMT_YUV422) {
126 4606ac8d Zdenek Kabelac
        desired_palette = VIDEO_PALETTE_YUV422;
127 76a77ff2 Luca Abeni
        desired_depth = 16;
128
    } else if (ap->pix_fmt == PIX_FMT_BGR24) {
129 4606ac8d Zdenek Kabelac
        desired_palette = VIDEO_PALETTE_RGB24;
130 76a77ff2 Luca Abeni
        desired_depth = 24;
131 115329f1 Diego Biurrun
    }
132 e3ee3283 Alex Beregszaszi
133
    /* set tv standard */
134
    if (ap->standard && !ioctl(video_fd, VIDIOCGTUNER, &tuner)) {
135 bb270c08 Diego Biurrun
        if (!strcasecmp(ap->standard, "pal"))
136
            tuner.mode = VIDEO_MODE_PAL;
137
        else if (!strcasecmp(ap->standard, "secam"))
138
            tuner.mode = VIDEO_MODE_SECAM;
139
        else
140
            tuner.mode = VIDEO_MODE_NTSC;
141
        ioctl(video_fd, VIDIOCSTUNER, &tuner);
142 e3ee3283 Alex Beregszaszi
    }
143 115329f1 Diego Biurrun
144 de6d9b64 Fabrice Bellard
    /* unmute audio */
145 8949367e Fabrice Bellard
    audio.audio = 0;
146 de6d9b64 Fabrice Bellard
    ioctl(video_fd, VIDIOCGAUDIO, &audio);
147 8949367e Fabrice Bellard
    memcpy(&s->audio_saved, &audio, sizeof(audio));
148 de6d9b64 Fabrice Bellard
    audio.flags &= ~VIDEO_AUDIO_MUTE;
149
    ioctl(video_fd, VIDIOCSAUDIO, &audio);
150
151 c787ba85 Flavio Pimentel Duarte
    ioctl(video_fd, VIDIOCGPICT, &pict);
152
#if 0
153
    printf("v4l: colour=%d hue=%d brightness=%d constrast=%d whiteness=%d\n",
154
           pict.colour,
155
           pict.hue,
156
           pict.brightness,
157
           pict.contrast,
158
           pict.whiteness);
159
#endif
160
    /* try to choose a suitable video format */
161
    pict.palette = desired_palette;
162 76a77ff2 Luca Abeni
    pict.depth= desired_depth;
163 c787ba85 Flavio Pimentel Duarte
    if (desired_palette == -1 || (ret = ioctl(video_fd, VIDIOCSPICT, &pict)) < 0) {
164
        pict.palette=VIDEO_PALETTE_YUV420P;
165 76a77ff2 Luca Abeni
        pict.depth=12;
166 c787ba85 Flavio Pimentel Duarte
        ret = ioctl(video_fd, VIDIOCSPICT, &pict);
167
        if (ret < 0) {
168
            pict.palette=VIDEO_PALETTE_YUV422;
169 76a77ff2 Luca Abeni
            pict.depth=16;
170 c787ba85 Flavio Pimentel Duarte
            ret = ioctl(video_fd, VIDIOCSPICT, &pict);
171
            if (ret < 0) {
172
                pict.palette=VIDEO_PALETTE_RGB24;
173 76a77ff2 Luca Abeni
                pict.depth=24;
174 c787ba85 Flavio Pimentel Duarte
                ret = ioctl(video_fd, VIDIOCSPICT, &pict);
175
                if (ret < 0)
176
                    goto fail1;
177
            }
178
        }
179
    }
180
181 8949367e Fabrice Bellard
    ret = ioctl(video_fd,VIDIOCGMBUF,&s->gb_buffers);
182 de6d9b64 Fabrice Bellard
    if (ret < 0) {
183
        /* try to use read based access */
184
        struct video_window win;
185
        int val;
186
187
        win.x = 0;
188
        win.y = 0;
189
        win.width = width;
190
        win.height = height;
191
        win.chromakey = -1;
192
        win.flags = 0;
193
194
        ioctl(video_fd, VIDIOCSWIN, &win);
195
196
        s->frame_format = pict.palette;
197
198
        val = 1;
199
        ioctl(video_fd, VIDIOCCAPTURE, &val);
200
201 3834be58 Luca Abeni
        s->time_frame = av_gettime() * s->frame_rate / s->frame_rate_base;
202 de6d9b64 Fabrice Bellard
        s->use_mmap = 0;
203 115329f1 Diego Biurrun
204 8949367e Fabrice Bellard
        /* ATI All In Wonder automatic activation */
205
        if (!strcmp(s->video_cap.name, "Km")) {
206
            if (aiw_init(s) < 0)
207
                goto fail;
208
            s->aiw_enabled = 1;
209
            /* force 420P format because convertion from YUV422 to YUV420P
210
               is done in this driver (ugly) */
211
            s->frame_format = VIDEO_PALETTE_YUV420P;
212
        }
213 de6d9b64 Fabrice Bellard
    } else {
214 8949367e Fabrice Bellard
        s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_SHARED,video_fd,0);
215
        if ((unsigned char*)-1 == s->video_buf) {
216 de6d9b64 Fabrice Bellard
            perror("mmap");
217
            goto fail;
218
        }
219 8949367e Fabrice Bellard
        s->gb_frame = 0;
220 3834be58 Luca Abeni
        s->time_frame = av_gettime() * s->frame_rate / s->frame_rate_base;
221 115329f1 Diego Biurrun
222 de6d9b64 Fabrice Bellard
        /* start to grab the first frame */
223 8949367e Fabrice Bellard
        s->gb_buf.frame = s->gb_frame % s->gb_buffers.frames;
224
        s->gb_buf.height = height;
225
        s->gb_buf.width = width;
226 c787ba85 Flavio Pimentel Duarte
        s->gb_buf.format = pict.palette;
227
228
        ret = ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
229 de6d9b64 Fabrice Bellard
        if (ret < 0) {
230
            if (errno != EAGAIN) {
231
            fail1:
232 bc874dae Michel Bardiaux
                av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not support suitable format\n");
233 de6d9b64 Fabrice Bellard
            } else {
234 bc874dae Michel Bardiaux
                av_log(s1, AV_LOG_ERROR,"Fatal: grab device does not receive any video signal\n");
235 de6d9b64 Fabrice Bellard
            }
236
            goto fail;
237
        }
238 bb270c08 Diego Biurrun
        for (j = 1; j < s->gb_buffers.frames; j++) {
239
          s->gb_buf.frame = j;
240
          ioctl(video_fd, VIDIOCMCAPTURE, &s->gb_buf);
241
        }
242 8949367e Fabrice Bellard
        s->frame_format = s->gb_buf.format;
243 de6d9b64 Fabrice Bellard
        s->use_mmap = 1;
244
    }
245
246
    switch(s->frame_format) {
247
    case VIDEO_PALETTE_YUV420P:
248
        frame_size = (width * height * 3) / 2;
249 01f4895c Michael Niedermayer
        st->codec->pix_fmt = PIX_FMT_YUV420P;
250 de6d9b64 Fabrice Bellard
        break;
251
    case VIDEO_PALETTE_YUV422:
252
        frame_size = width * height * 2;
253 01f4895c Michael Niedermayer
        st->codec->pix_fmt = PIX_FMT_YUV422;
254 de6d9b64 Fabrice Bellard
        break;
255
    case VIDEO_PALETTE_RGB24:
256
        frame_size = width * height * 3;
257 01f4895c Michael Niedermayer
        st->codec->pix_fmt = PIX_FMT_BGR24; /* NOTE: v4l uses BGR24, not RGB24 ! */
258 de6d9b64 Fabrice Bellard
        break;
259
    default:
260
        goto fail;
261
    }
262
    s->fd = video_fd;
263 4972b26f Fabrice Bellard
    s->frame_size = frame_size;
264 115329f1 Diego Biurrun
265 01f4895c Michael Niedermayer
    st->codec->codec_type = CODEC_TYPE_VIDEO;
266
    st->codec->codec_id = CODEC_ID_RAWVIDEO;
267
    st->codec->width = width;
268
    st->codec->height = height;
269
    st->codec->time_base.den      = frame_rate;
270
    st->codec->time_base.num = frame_rate_base;
271 4209fad9 Alex Beregszaszi
    st->codec->bit_rate = frame_size * 1/av_q2d(st->codec->time_base) * 8;
272 45dd5c69 Fabrice Bellard
273 de6d9b64 Fabrice Bellard
    return 0;
274
 fail:
275 4972b26f Fabrice Bellard
    if (video_fd >= 0)
276
        close(video_fd);
277 1ea4f593 Fabrice Bellard
    av_free(st);
278 0bd586c5 Mike Melanson
    return AVERROR_IO;
279 de6d9b64 Fabrice Bellard
}
280
281 0c1a9eda Zdenek Kabelac
static int v4l_mm_read_picture(VideoData *s, uint8_t *buf)
282 de6d9b64 Fabrice Bellard
{
283 0c1a9eda Zdenek Kabelac
    uint8_t *ptr;
284 de6d9b64 Fabrice Bellard
285 7aae3168 Michael Niedermayer
    while (ioctl(s->fd, VIDIOCSYNC, &s->gb_frame) < 0 &&
286
           (errno == EAGAIN || errno == EINTR));
287
288
    ptr = s->video_buf + s->gb_buffers.offsets[s->gb_frame];
289
    memcpy(buf, ptr, s->frame_size);
290
291 4606ac8d Zdenek Kabelac
    /* Setup to capture the next frame */
292 7aae3168 Michael Niedermayer
    s->gb_buf.frame = s->gb_frame;
293 8949367e Fabrice Bellard
    if (ioctl(s->fd, VIDIOCMCAPTURE, &s->gb_buf) < 0) {
294 28c66901 Philip Gladstone
        if (errno == EAGAIN)
295 bc874dae Michel Bardiaux
            av_log(NULL, AV_LOG_ERROR, "Cannot Sync\n");
296 28c66901 Philip Gladstone
        else
297 de6d9b64 Fabrice Bellard
            perror("VIDIOCMCAPTURE");
298 0bd586c5 Mike Melanson
        return AVERROR_IO;
299 de6d9b64 Fabrice Bellard
    }
300 4606ac8d Zdenek Kabelac
301
    /* This is now the grabbing frame */
302 7aae3168 Michael Niedermayer
    s->gb_frame = (s->gb_frame + 1) % s->gb_buffers.frames;
303 4606ac8d Zdenek Kabelac
304 4972b26f Fabrice Bellard
    return s->frame_size;
305 de6d9b64 Fabrice Bellard
}
306
307 4972b26f Fabrice Bellard
static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
308 de6d9b64 Fabrice Bellard
{
309 4972b26f Fabrice Bellard
    VideoData *s = s1->priv_data;
310 0c1a9eda Zdenek Kabelac
    int64_t curtime, delay;
311 4972b26f Fabrice Bellard
    struct timespec ts;
312 4606ac8d Zdenek Kabelac
313
    /* Calculate the time of the next frame */
314 3834be58 Luca Abeni
    s->time_frame += int64_t_C(1000000);
315 de6d9b64 Fabrice Bellard
316
    /* wait based on the frame rate */
317 45dd5c69 Fabrice Bellard
    for(;;) {
318 a11bf0bd Fabrice Bellard
        curtime = av_gettime();
319 3834be58 Luca Abeni
        delay = s->time_frame  * s->frame_rate_base / s->frame_rate - curtime;
320 4606ac8d Zdenek Kabelac
        if (delay <= 0) {
321 3834be58 Luca Abeni
            if (delay < int64_t_C(-1000000) * s->frame_rate_base / s->frame_rate) {
322 4606ac8d Zdenek Kabelac
                /* printf("grabbing is %d frames late (dropping)\n", (int) -(delay / 16666)); */
323 3834be58 Luca Abeni
                s->time_frame += int64_t_C(1000000);
324 4606ac8d Zdenek Kabelac
            }
325 4972b26f Fabrice Bellard
            break;
326 115329f1 Diego Biurrun
        }
327 4972b26f Fabrice Bellard
        ts.tv_sec = delay / 1000000;
328
        ts.tv_nsec = (delay % 1000000) * 1000;
329
        nanosleep(&ts, NULL);
330
    }
331
332
    if (av_new_packet(pkt, s->frame_size) < 0)
333 0bd586c5 Mike Melanson
        return AVERROR_IO;
334 de6d9b64 Fabrice Bellard
335 0a7b514f Luca Abeni
    pkt->pts = curtime;
336 45dd5c69 Fabrice Bellard
337 de6d9b64 Fabrice Bellard
    /* read one frame */
338 8949367e Fabrice Bellard
    if (s->aiw_enabled) {
339
        return aiw_read_picture(s, pkt->data);
340
    } else if (s->use_mmap) {
341 4972b26f Fabrice Bellard
        return v4l_mm_read_picture(s, pkt->data);
342 de6d9b64 Fabrice Bellard
    } else {
343 4972b26f Fabrice Bellard
        if (read(s->fd, pkt->data, pkt->size) != pkt->size)
344 0bd586c5 Mike Melanson
            return AVERROR_IO;
345 4972b26f Fabrice Bellard
        return s->frame_size;
346 de6d9b64 Fabrice Bellard
    }
347
}
348
349 4972b26f Fabrice Bellard
static int grab_read_close(AVFormatContext *s1)
350 de6d9b64 Fabrice Bellard
{
351 4972b26f Fabrice Bellard
    VideoData *s = s1->priv_data;
352 e61efa24 Lennert Buytenhek
353 8949367e Fabrice Bellard
    if (s->aiw_enabled)
354
        aiw_close(s);
355
356 e61efa24 Lennert Buytenhek
    if (s->use_mmap)
357 8949367e Fabrice Bellard
        munmap(s->video_buf, s->gb_buffers.size);
358 e61efa24 Lennert Buytenhek
359 8949367e Fabrice Bellard
    /* mute audio. we must force it because the BTTV driver does not
360
       return its state correctly */
361
    s->audio_saved.flags |= VIDEO_AUDIO_MUTE;
362
    ioctl(s->fd, VIDIOCSAUDIO, &s->audio_saved);
363 5a56c87c Fabrice Bellard
364 de6d9b64 Fabrice Bellard
    close(s->fd);
365
    return 0;
366
}
367
368 ff70e601 Måns Rullgård
AVInputFormat video_grab_device_demuxer = {
369 8aa3ee32 Max Krasnyansky
    "video4linux",
370 4972b26f Fabrice Bellard
    "video grab",
371 c9a65ca8 Fabrice Bellard
    sizeof(VideoData),
372 4972b26f Fabrice Bellard
    NULL,
373
    grab_read_header,
374
    grab_read_packet,
375
    grab_read_close,
376 bb76a117 Måns Rullgård
    .flags = AVFMT_NOFILE,
377 de6d9b64 Fabrice Bellard
};
378 c9a65ca8 Fabrice Bellard
379 8949367e Fabrice Bellard
/* All in Wonder specific stuff */
380
/* XXX: remove and merge in libavcodec/imgconvert.c */
381 3f9bff71 Michael Niedermayer
382 8949367e Fabrice Bellard
static int aiw_init(VideoData *s)
383 3f9bff71 Michael Niedermayer
{
384
    int width, height;
385
386 8949367e Fabrice Bellard
    width = s->width;
387
    height = s->height;
388 3f9bff71 Michael Niedermayer
389 8949367e Fabrice Bellard
    if ((width == s->video_cap.maxwidth && height == s->video_cap.maxheight) ||
390
        (width == s->video_cap.maxwidth && height == s->video_cap.maxheight*2) ||
391
        (width == s->video_cap.maxwidth/2 && height == s->video_cap.maxheight)) {
392 115329f1 Diego Biurrun
393 8949367e Fabrice Bellard
        s->deint=0;
394
        s->halfw=0;
395
        if (height == s->video_cap.maxheight*2) s->deint=1;
396
        if (width == s->video_cap.maxwidth/2) s->halfw=1;
397 3f9bff71 Michael Niedermayer
    } else {
398 bc874dae Michel Bardiaux
        av_log(NULL, AV_LOG_ERROR, "\nIncorrect Grab Size Supplied - Supported Sizes Are:\n");
399
        av_log(NULL, AV_LOG_ERROR, " %dx%d  %dx%d %dx%d\n\n",
400 8949367e Fabrice Bellard
                s->video_cap.maxwidth,s->video_cap.maxheight,
401
                s->video_cap.maxwidth,s->video_cap.maxheight*2,
402
                s->video_cap.maxwidth/2,s->video_cap.maxheight);
403 3f9bff71 Michael Niedermayer
        goto fail;
404
    }
405
406
    if (s->halfw == 0) {
407
        s->src_mem = av_malloc(s->width*2);
408
    } else {
409
        s->src_mem = av_malloc(s->width*4);
410
    }
411
    if (!s->src_mem) goto fail;
412
413
    s->lum_m4_mem = av_malloc(s->width);
414 8949367e Fabrice Bellard
    if (!s->lum_m4_mem)
415 3f9bff71 Michael Niedermayer
        goto fail;
416
    return 0;
417
 fail:
418 8949367e Fabrice Bellard
    av_freep(&s->src_mem);
419
    av_freep(&s->lum_m4_mem);
420
    return -1;
421 3f9bff71 Michael Niedermayer
}
422
423
#ifdef HAVE_MMX
424 6f72dcf7 Diego Biurrun
#include "libavcodec/i386/mmx.h"
425 3f9bff71 Michael Niedermayer
426
#define LINE_WITH_UV \
427
                    movq_m2r(ptr[0],mm0); \
428
                    movq_m2r(ptr[8],mm1);  \
429
                    movq_r2r(mm0, mm4); \
430
                    punpcklbw_r2r(mm1,mm0); \
431
                    punpckhbw_r2r(mm1,mm4); \
432
                    movq_r2r(mm0,mm5); \
433
                    punpcklbw_r2r(mm4,mm0); \
434
                    punpckhbw_r2r(mm4,mm5); \
435
                    movq_r2r(mm0,mm1); \
436
                    punpcklbw_r2r(mm5,mm1); \
437
                    movq_r2m(mm1,lum[0]); \
438
                    movq_m2r(ptr[16],mm2); \
439
                    movq_m2r(ptr[24],mm1); \
440
                    movq_r2r(mm2,mm4); \
441
                    punpcklbw_r2r(mm1,mm2); \
442
                    punpckhbw_r2r(mm1,mm4); \
443
                    movq_r2r(mm2,mm3); \
444
                    punpcklbw_r2r(mm4,mm2); \
445
                    punpckhbw_r2r(mm4,mm3); \
446
                    movq_r2r(mm2,mm1); \
447
                    punpcklbw_r2r(mm3,mm1); \
448
                    movq_r2m(mm1,lum[8]); \
449
                    punpckhdq_r2r(mm2,mm0); \
450
                    punpckhdq_r2r(mm3,mm5); \
451
                    movq_r2m(mm0,cb[0]); \
452
                    movq_r2m(mm5,cr[0]);
453
454
#define LINE_NO_UV \
455
                    movq_m2r(ptr[0],mm0);\
456
                    movq_m2r(ptr[8],mm1);\
457
                    movq_r2r(mm0, mm4);\
458
                    punpcklbw_r2r(mm1,mm0); \
459
                    punpckhbw_r2r(mm1,mm4);\
460
                    movq_r2r(mm0,mm5);\
461
                    punpcklbw_r2r(mm4,mm0);\
462
                    punpckhbw_r2r(mm4,mm5);\
463
                    movq_r2r(mm0,mm1);\
464
                    punpcklbw_r2r(mm5,mm1);\
465
                    movq_r2m(mm1,lum[0]);\
466
                    movq_m2r(ptr[16],mm2);\
467
                    movq_m2r(ptr[24],mm1);\
468
                    movq_r2r(mm2,mm4);\
469
                    punpcklbw_r2r(mm1,mm2);\
470
                    punpckhbw_r2r(mm1,mm4);\
471
                    movq_r2r(mm2,mm3);\
472
                    punpcklbw_r2r(mm4,mm2);\
473
                    punpckhbw_r2r(mm4,mm3);\
474
                    movq_r2r(mm2,mm1);\
475
                    punpcklbw_r2r(mm3,mm1);\
476
                    movq_r2m(mm1,lum[8]);
477
478
#define LINE_WITHUV_AVG \
479
                    movq_m2r(ptr[0], mm0);\
480
                    movq_m2r(ptr[8], mm1);\
481
                    movq_r2r(mm0, mm4);\
482
                    punpcklbw_r2r(mm1,mm0);\
483
                    punpckhbw_r2r(mm1,mm4);\
484
                    movq_r2r(mm0,mm5);\
485
                    punpcklbw_r2r(mm4,mm0);\
486
                    punpckhbw_r2r(mm4,mm5);\
487
                    movq_r2r(mm0,mm1);\
488
                    movq_r2r(mm5,mm2);\
489
                    punpcklbw_r2r(mm7,mm1);\
490
                    punpcklbw_r2r(mm7,mm2);\
491
                    paddw_r2r(mm6,mm1);\
492
                    paddw_r2r(mm2,mm1);\
493
                    psraw_i2r(1,mm1);\
494
                    packuswb_r2r(mm7,mm1);\
495
                    movd_r2m(mm1,lum[0]);\
496
                    movq_m2r(ptr[16],mm2);\
497
                    movq_m2r(ptr[24],mm1);\
498
                    movq_r2r(mm2,mm4);\
499
                    punpcklbw_r2r(mm1,mm2);\
500
                    punpckhbw_r2r(mm1,mm4);\
501
                    movq_r2r(mm2,mm3);\
502
                    punpcklbw_r2r(mm4,mm2);\
503
                    punpckhbw_r2r(mm4,mm3);\
504
                    movq_r2r(mm2,mm1);\
505
                    movq_r2r(mm3,mm4);\
506
                    punpcklbw_r2r(mm7,mm1);\
507
                    punpcklbw_r2r(mm7,mm4);\
508
                    paddw_r2r(mm6,mm1);\
509
                    paddw_r2r(mm4,mm1);\
510
                    psraw_i2r(1,mm1);\
511
                    packuswb_r2r(mm7,mm1);\
512
                    movd_r2m(mm1,lum[4]);\
513
                    punpckhbw_r2r(mm7,mm0);\
514
                    punpckhbw_r2r(mm7,mm2);\
515
                    paddw_r2r(mm6,mm0);\
516
                    paddw_r2r(mm2,mm0);\
517
                    psraw_i2r(1,mm0);\
518
                    packuswb_r2r(mm7,mm0);\
519
                    punpckhbw_r2r(mm7,mm5);\
520
                    punpckhbw_r2r(mm7,mm3);\
521
                    paddw_r2r(mm6,mm5);\
522
                    paddw_r2r(mm3,mm5);\
523
                    psraw_i2r(1,mm5);\
524
                    packuswb_r2r(mm7,mm5);\
525
                    movd_r2m(mm0,cb[0]);\
526
                    movd_r2m(mm5,cr[0]);
527
528
#define LINE_NOUV_AVG \
529
                    movq_m2r(ptr[0],mm0);\
530
                    movq_m2r(ptr[8],mm1);\
531
                    pand_r2r(mm5,mm0);\
532
                    pand_r2r(mm5,mm1);\
533
                    pmaddwd_r2r(mm6,mm0);\
534
                    pmaddwd_r2r(mm6,mm1);\
535
                    packssdw_r2r(mm1,mm0);\
536
                    paddw_r2r(mm6,mm0);\
537
                    psraw_i2r(1,mm0);\
538
                    movq_m2r(ptr[16],mm2);\
539
                    movq_m2r(ptr[24],mm3);\
540
                    pand_r2r(mm5,mm2);\
541
                    pand_r2r(mm5,mm3);\
542
                    pmaddwd_r2r(mm6,mm2);\
543
                    pmaddwd_r2r(mm6,mm3);\
544
                    packssdw_r2r(mm3,mm2);\
545
                    paddw_r2r(mm6,mm2);\
546
                    psraw_i2r(1,mm2);\
547
                    packuswb_r2r(mm2,mm0);\
548
                    movq_r2m(mm0,lum[0]);
549
550
#define DEINT_LINE_LUM(ptroff) \
551
                    movd_m2r(lum_m4[(ptroff)],mm0);\
552
                    movd_m2r(lum_m3[(ptroff)],mm1);\
553
                    movd_m2r(lum_m2[(ptroff)],mm2);\
554
                    movd_m2r(lum_m1[(ptroff)],mm3);\
555
                    movd_m2r(lum[(ptroff)],mm4);\
556
                    punpcklbw_r2r(mm7,mm0);\
557
                    movd_r2m(mm2,lum_m4[(ptroff)]);\
558
                    punpcklbw_r2r(mm7,mm1);\
559
                    punpcklbw_r2r(mm7,mm2);\
560
                    punpcklbw_r2r(mm7,mm3);\
561
                    punpcklbw_r2r(mm7,mm4);\
562
                    psllw_i2r(2,mm1);\
563
                    psllw_i2r(1,mm2);\
564
                    paddw_r2r(mm6,mm1);\
565
                    psllw_i2r(2,mm3);\
566
                    paddw_r2r(mm2,mm1);\
567
                    paddw_r2r(mm4,mm0);\
568
                    paddw_r2r(mm3,mm1);\
569
                    psubusw_r2r(mm0,mm1);\
570
                    psrlw_i2r(3,mm1);\
571
                    packuswb_r2r(mm7,mm1);\
572
                    movd_r2m(mm1,lum_m2[(ptroff)]);
573
574
#else
575 6f72dcf7 Diego Biurrun
#include "libavcodec/dsputil.h"
576 3f9bff71 Michael Niedermayer
577
#define LINE_WITH_UV \
578
                    lum[0]=ptr[0];lum[1]=ptr[2];lum[2]=ptr[4];lum[3]=ptr[6];\
579
                    cb[0]=ptr[1];cb[1]=ptr[5];\
580
                    cr[0]=ptr[3];cr[1]=ptr[7];\
581
                    lum[4]=ptr[8];lum[5]=ptr[10];lum[6]=ptr[12];lum[7]=ptr[14];\
582
                    cb[2]=ptr[9];cb[3]=ptr[13];\
583
                    cr[2]=ptr[11];cr[3]=ptr[15];\
584
                    lum[8]=ptr[16];lum[9]=ptr[18];lum[10]=ptr[20];lum[11]=ptr[22];\
585
                    cb[4]=ptr[17];cb[5]=ptr[21];\
586
                    cr[4]=ptr[19];cr[5]=ptr[23];\
587
                    lum[12]=ptr[24];lum[13]=ptr[26];lum[14]=ptr[28];lum[15]=ptr[30];\
588
                    cb[6]=ptr[25];cb[7]=ptr[29];\
589
                    cr[6]=ptr[27];cr[7]=ptr[31];
590
591
#define LINE_NO_UV \
592
                    lum[0]=ptr[0];lum[1]=ptr[2];lum[2]=ptr[4];lum[3]=ptr[6];\
593
                    lum[4]=ptr[8];lum[5]=ptr[10];lum[6]=ptr[12];lum[7]=ptr[14];\
594
                    lum[8]=ptr[16];lum[9]=ptr[18];lum[10]=ptr[20];lum[11]=ptr[22];\
595
                    lum[12]=ptr[24];lum[13]=ptr[26];lum[14]=ptr[28];lum[15]=ptr[30];
596
597
#define LINE_WITHUV_AVG \
598
                    sum=(ptr[0]+ptr[2]+1) >> 1;lum[0]=sum; \
599
                    sum=(ptr[4]+ptr[6]+1) >> 1;lum[1]=sum; \
600
                    sum=(ptr[1]+ptr[5]+1) >> 1;cb[0]=sum; \
601
                    sum=(ptr[3]+ptr[7]+1) >> 1;cr[0]=sum; \
602
                    sum=(ptr[8]+ptr[10]+1) >> 1;lum[2]=sum; \
603
                    sum=(ptr[12]+ptr[14]+1) >> 1;lum[3]=sum; \
604
                    sum=(ptr[9]+ptr[13]+1) >> 1;cb[1]=sum; \
605
                    sum=(ptr[11]+ptr[15]+1) >> 1;cr[1]=sum; \
606
                    sum=(ptr[16]+ptr[18]+1) >> 1;lum[4]=sum; \
607
                    sum=(ptr[20]+ptr[22]+1) >> 1;lum[5]=sum; \
608
                    sum=(ptr[17]+ptr[21]+1) >> 1;cb[2]=sum; \
609
                    sum=(ptr[19]+ptr[23]+1) >> 1;cr[2]=sum; \
610
                    sum=(ptr[24]+ptr[26]+1) >> 1;lum[6]=sum; \
611
                    sum=(ptr[28]+ptr[30]+1) >> 1;lum[7]=sum; \
612
                    sum=(ptr[25]+ptr[29]+1) >> 1;cb[3]=sum; \
613 115329f1 Diego Biurrun
                    sum=(ptr[27]+ptr[31]+1) >> 1;cr[3]=sum;
614 3f9bff71 Michael Niedermayer
615
#define LINE_NOUV_AVG \
616
                    sum=(ptr[0]+ptr[2]+1) >> 1;lum[0]=sum; \
617
                    sum=(ptr[4]+ptr[6]+1) >> 1;lum[1]=sum; \
618
                    sum=(ptr[8]+ptr[10]+1) >> 1;lum[2]=sum; \
619
                    sum=(ptr[12]+ptr[14]+1) >> 1;lum[3]=sum; \
620
                    sum=(ptr[16]+ptr[18]+1) >> 1;lum[4]=sum; \
621
                    sum=(ptr[20]+ptr[22]+1) >> 1;lum[5]=sum; \
622
                    sum=(ptr[24]+ptr[26]+1) >> 1;lum[6]=sum; \
623 115329f1 Diego Biurrun
                    sum=(ptr[28]+ptr[30]+1) >> 1;lum[7]=sum;
624 3f9bff71 Michael Niedermayer
625
#define DEINT_LINE_LUM(ptroff) \
626
                    sum=(-lum_m4[(ptroff)]+(lum_m3[(ptroff)]<<2)+(lum_m2[(ptroff)]<<1)+(lum_m1[(ptroff)]<<2)-lum[(ptroff)]); \
627
                    lum_m4[(ptroff)]=lum_m2[(ptroff)];\
628
                    lum_m2[(ptroff)]=cm[(sum+4)>>3];\
629
                    sum=(-lum_m4[(ptroff)+1]+(lum_m3[(ptroff)+1]<<2)+(lum_m2[(ptroff)+1]<<1)+(lum_m1[(ptroff)+1]<<2)-lum[(ptroff)+1]); \
630
                    lum_m4[(ptroff)+1]=lum_m2[(ptroff)+1];\
631
                    lum_m2[(ptroff)+1]=cm[(sum+4)>>3];\
632
                    sum=(-lum_m4[(ptroff)+2]+(lum_m3[(ptroff)+2]<<2)+(lum_m2[(ptroff)+2]<<1)+(lum_m1[(ptroff)+2]<<2)-lum[(ptroff)+2]); \
633
                    lum_m4[(ptroff)+2]=lum_m2[(ptroff)+2];\
634
                    lum_m2[(ptroff)+2]=cm[(sum+4)>>3];\
635
                    sum=(-lum_m4[(ptroff)+3]+(lum_m3[(ptroff)+3]<<2)+(lum_m2[(ptroff)+3]<<1)+(lum_m1[(ptroff)+3]<<2)-lum[(ptroff)+3]); \
636
                    lum_m4[(ptroff)+3]=lum_m2[(ptroff)+3];\
637
                    lum_m2[(ptroff)+3]=cm[(sum+4)>>3];
638
639
#endif
640
641
642 8949367e Fabrice Bellard
/* Read two fields separately. */
643
static int aiw_read_picture(VideoData *s, uint8_t *data)
644 3f9bff71 Michael Niedermayer
{
645 0c1a9eda Zdenek Kabelac
    uint8_t *ptr, *lum, *cb, *cr;
646 8949367e Fabrice Bellard
    int h;
647 3f9bff71 Michael Niedermayer
#ifndef HAVE_MMX
648 8949367e Fabrice Bellard
    int sum;
649 3f9bff71 Michael Niedermayer
#endif
650 0c1a9eda Zdenek Kabelac
    uint8_t* src = s->src_mem;
651
    uint8_t *ptrend = &src[s->width*2];
652 8949367e Fabrice Bellard
    lum=data;
653
    cb=&lum[s->width*s->height];
654
    cr=&cb[(s->width*s->height)/4];
655
    if (s->deint == 0 && s->halfw == 0) {
656
        while (read(s->fd,src,s->width*2) < 0) {
657
            usleep(100);
658
        }
659
        for (h = 0; h < s->height-2; h+=2) {
660 3f9bff71 Michael Niedermayer
            for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
661
                LINE_WITH_UV
662 8949367e Fabrice Bellard
                    }
663 3f9bff71 Michael Niedermayer
            read(s->fd,src,s->width*2);
664
            for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16) {
665
                LINE_NO_UV
666 8949367e Fabrice Bellard
                    }
667
            read(s->fd,src,s->width*2);
668
        }
669
        /*
670
         * Do last two lines
671
         */
672
        for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
673
            LINE_WITH_UV
674 3f9bff71 Michael Niedermayer
                }
675 8949367e Fabrice Bellard
        read(s->fd,src,s->width*2);
676
        for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16) {
677
            LINE_NO_UV
678
                }
679
        /* drop second field */
680
        while (read(s->fd,src,s->width*2) < 0) {
681
            usleep(100);
682
        }
683
        for (h = 0; h < s->height - 1; h++) {
684
            read(s->fd,src,s->width*2);
685
        }
686
    } else if (s->halfw == 1) {
687 3f9bff71 Michael Niedermayer
#ifdef HAVE_MMX
688 8949367e Fabrice Bellard
        mmx_t rounder;
689
        mmx_t masker;
690
        rounder.uw[0]=1;
691
        rounder.uw[1]=1;
692
        rounder.uw[2]=1;
693
        rounder.uw[3]=1;
694
        masker.ub[0]=0xff;
695
        masker.ub[1]=0;
696
        masker.ub[2]=0xff;
697
        masker.ub[3]=0;
698
        masker.ub[4]=0xff;
699
        masker.ub[5]=0;
700
        masker.ub[6]=0xff;
701
        masker.ub[7]=0;
702
        pxor_r2r(mm7,mm7);
703
        movq_m2r(rounder,mm6);
704 3f9bff71 Michael Niedermayer
#endif
705 8949367e Fabrice Bellard
        while (read(s->fd,src,s->width*4) < 0) {
706
            usleep(100);
707
        }
708
        ptrend = &src[s->width*4];
709
        for (h = 0; h < s->height-2; h+=2) {
710 3f9bff71 Michael Niedermayer
            for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8, cb+=4, cr+=4) {
711
                LINE_WITHUV_AVG
712 8949367e Fabrice Bellard
                    }
713 3f9bff71 Michael Niedermayer
            read(s->fd,src,s->width*4);
714
#ifdef HAVE_MMX
715
            movq_m2r(masker,mm5);
716
#endif
717
            for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8) {
718
                LINE_NOUV_AVG
719 8949367e Fabrice Bellard
                    }
720
            read(s->fd,src,s->width*4);
721
        }
722
        /*
723
 * Do last two lines
724
 */
725
        for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8, cb+=4, cr+=4) {
726
            LINE_WITHUV_AVG
727
                }
728
        read(s->fd,src,s->width*4);
729
#ifdef HAVE_MMX
730
        movq_m2r(masker,mm5);
731
#endif
732
        for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=8) {
733
            LINE_NOUV_AVG
734
                }
735
        /* drop second field */
736
        while (read(s->fd,src,s->width*4) < 0) {
737
            usleep(100);
738
        }
739
        for (h = 0; h < s->height - 1; h++) {
740
            read(s->fd,src,s->width*4);
741
        }
742
    } else {
743 0c1a9eda Zdenek Kabelac
        uint8_t *lum_m1, *lum_m2, *lum_m3, *lum_m4;
744 3f9bff71 Michael Niedermayer
#ifdef HAVE_MMX
745 8949367e Fabrice Bellard
        mmx_t rounder;
746
        rounder.uw[0]=4;
747
        rounder.uw[1]=4;
748
        rounder.uw[2]=4;
749
        rounder.uw[3]=4;
750
        movq_m2r(rounder,mm6);
751
        pxor_r2r(mm7,mm7);
752 3f9bff71 Michael Niedermayer
#else
753 0c1a9eda Zdenek Kabelac
        uint8_t *cm = cropTbl + MAX_NEG_CROP;
754 3f9bff71 Michael Niedermayer
#endif
755
756 8949367e Fabrice Bellard
        /* read two fields and deinterlace them */
757
        while (read(s->fd,src,s->width*2) < 0) {
758
            usleep(100);
759
        }
760
        for (h = 0; h < (s->height/2)-2; h+=2) {
761 3f9bff71 Michael Niedermayer
            for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
762
                LINE_WITH_UV
763 8949367e Fabrice Bellard
                    }
764 3f9bff71 Michael Niedermayer
            read(s->fd,src,s->width*2);
765 8949367e Fabrice Bellard
            /* skip a luminance line - will be filled in later */
766
            lum += s->width;
767 3f9bff71 Michael Niedermayer
            for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
768
                LINE_WITH_UV
769 8949367e Fabrice Bellard
                    }
770
            /* skip a luminance line - will be filled in later */
771
            lum += s->width;
772
            read(s->fd,src,s->width*2);
773
        }
774
        /*
775
 * Do last two lines
776
 */
777
        for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
778
            LINE_WITH_UV
779
                }
780
        /* skip a luminance line - will be filled in later */
781
        lum += s->width;
782
        read(s->fd,src,s->width*2);
783
        for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, cb+=8, cr+=8) {
784
            LINE_WITH_UV
785
                }
786
        /*
787 3f9bff71 Michael Niedermayer
 *
788
 * SECOND FIELD
789
 *
790
 */
791 8949367e Fabrice Bellard
        lum=&data[s->width];
792
        while (read(s->fd,src,s->width*2) < 0) {
793
            usleep(10);
794
        }
795
        /* First (and last) two lines not interlaced */
796
        for (h = 0; h < 2; h++) {
797
            for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16) {
798
                LINE_NO_UV
799
                    }
800
            read(s->fd,src,s->width*2);
801
            /* skip a luminance line */
802
            lum += s->width;
803
        }
804
        lum_m1=&lum[-s->width];
805
        lum_m2=&lum_m1[-s->width];
806
        lum_m3=&lum_m2[-s->width];
807
        memmove(s->lum_m4_mem,&lum_m3[-s->width],s->width);
808
        for (; h < (s->height/2)-1; h++) {
809
            lum_m4=s->lum_m4_mem;
810
            for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16,lum_m1+=16,lum_m2+=16,lum_m3+=16,lum_m4+=16) {
811
                LINE_NO_UV
812 3f9bff71 Michael Niedermayer
813
                    DEINT_LINE_LUM(0)
814
                    DEINT_LINE_LUM(4)
815
                    DEINT_LINE_LUM(8)
816
                    DEINT_LINE_LUM(12)
817 8949367e Fabrice Bellard
                    }
818
            read(s->fd,src,s->width*2);
819
            /* skip a luminance line */
820
            lum += s->width;
821
            lum_m1 += s->width;
822
            lum_m2 += s->width;
823
            lum_m3 += s->width;
824
            //                lum_m4 += s->width;
825
        }
826
        /*
827 3f9bff71 Michael Niedermayer
 * Do last line
828
 */
829 8949367e Fabrice Bellard
        lum_m4=s->lum_m4_mem;
830
        for (ptr = &src[0]; ptr < ptrend; ptr+=32, lum+=16, lum_m1+=16, lum_m2+=16, lum_m3+=16, lum_m4+=16) {
831
            LINE_NO_UV
832 3f9bff71 Michael Niedermayer
833
                DEINT_LINE_LUM(0)
834
                DEINT_LINE_LUM(4)
835
                DEINT_LINE_LUM(8)
836
                DEINT_LINE_LUM(12)
837 8949367e Fabrice Bellard
                }
838
    }
839 3f9bff71 Michael Niedermayer
#ifdef HAVE_MMX
840 8949367e Fabrice Bellard
    emms();
841 3f9bff71 Michael Niedermayer
#endif
842
    return s->frame_size;
843
}
844
845 8949367e Fabrice Bellard
static int aiw_close(VideoData *s)
846 3f9bff71 Michael Niedermayer
{
847 8949367e Fabrice Bellard
    av_freep(&s->lum_m4_mem);
848
    av_freep(&s->src_mem);
849 3f9bff71 Michael Niedermayer
    return 0;
850
}