Revision ad97e414 libavformat/yuv4mpeg.c

View differences:

libavformat/yuv4mpeg.c
24 24

  
25 25
#ifdef CONFIG_MUXERS
26 26

  
27
struct frame_attributes {
28
    int interlaced_frame;
29
    int top_field_first;
30
};
31

  
27 32
static int yuv4_generate_header(AVFormatContext *s, char* buf)
28 33
{
29 34
    AVStream *st;
......
191 196
    char *tokstart,*tokend,*header_end;
192 197
    int i;
193 198
    ByteIOContext *pb = &s->pb;
194
    int width=-1, height=-1, raten=0, rated=0, aspectn=0, aspectd=0,interlaced_frame=0,top_field_first=0;
199
    int width=-1, height=-1, raten=0, rated=0, aspectn=0, aspectd=0;
195 200
    enum PixelFormat pix_fmt=PIX_FMT_NONE,alt_pix_fmt=PIX_FMT_NONE;
196 201
    AVStream *st;
202
    struct frame_attributes *s1 = s->priv_data;
197 203

  
198 204
    for (i=0; i<MAX_YUV4_HEADER; i++) {
199 205
        header[i] = get_byte(pb);
......
206 212
    if (i == MAX_YUV4_HEADER) return -1;
207 213
    if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC))) return -1;
208 214

  
215
    s1->interlaced_frame = 0;
216
    s1->top_field_first = 0;
209 217
    header_end = &header[i+1]; // Include space
210 218
    for(tokstart = &header[strlen(Y4M_MAGIC) + 1]; tokstart < header_end; tokstart++) {
211 219
        if (*tokstart==0x20) continue;
......
247 255
            case '?':
248 256
                break;
249 257
            case 'p':
250
                interlaced_frame=0;
258
                s1->interlaced_frame=0;
251 259
                break;
252 260
            case 't':
253
                interlaced_frame=1;
254
                top_field_first=1;
261
                s1->interlaced_frame=1;
262
                s1->top_field_first=1;
255 263
                break;
256 264
            case 'b':
257
                interlaced_frame=1;
258
                top_field_first=0;
265
                s1->interlaced_frame=1;
266
                s1->top_field_first=0;
259 267
                break;
260 268
            case 'm':
261 269
                av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed interlaced and non-interlaced frames.\n");
......
338 346
    char header[MAX_FRAME_HEADER+1];
339 347
    int packet_size, width, height;
340 348
    AVStream *st = s->streams[0];
349
    struct frame_attributes *s1 = s->priv_data;
341 350

  
342 351
    for (i=0; i<MAX_FRAME_HEADER; i++) {
343 352
        header[i] = get_byte(&s->pb);
......
359 368
    if (av_get_packet(&s->pb, pkt, packet_size) != packet_size)
360 369
        return AVERROR_IO;
361 370

  
371
    if (s->streams[0]->codec->coded_frame) {
372
        s->streams[0]->codec->coded_frame->interlaced_frame = s1->interlaced_frame;
373
        s->streams[0]->codec->coded_frame->top_field_first = s1->top_field_first;
374
    }
375

  
362 376
    pkt->stream_index = 0;
363 377
    return 0;
364 378
}
......
382 396
AVInputFormat yuv4mpegpipe_iformat = {
383 397
    "yuv4mpegpipe",
384 398
    "YUV4MPEG pipe format",
385
    0,
399
    sizeof(struct frame_attributes),
386 400
    yuv4_probe,
387 401
    yuv4_read_header,
388 402
    yuv4_read_packet,

Also available in: Unified diff