Revision 0bb240ac libavformat/img2.c

View differences:

libavformat/img2.c
32 32
    int img_number;
33 33
    int img_count;
34 34
    int is_pipe;
35
    int split_planes;  /**< use independent file for each Y, U, V plane */
35 36
    char path[1024];
36 37
} VideoData;
37 38

  
......
241 242
        st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
242 243
        st->codec->codec_id = s1->audio_codec_id;
243 244
    }else{
245
        const char *str= strrchr(s->path, '.');
246
        s->split_planes = str && !strcasecmp(str + 1, "y");
244 247
        st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
245 248
        st->codec->codec_id = av_str2id(img_tags, s->path);
246 249
    }
......
278 281
            }
279 282
            size[i]= avio_size(f[i]);
280 283

  
281
            if(codec->codec_id != CODEC_ID_RAWVIDEO)
284
            if(!s->split_planes)
282 285
                break;
283 286
            filename[ strlen(filename) - 1 ]= 'U' + i;
284 287
        }
......
324 327
static int write_header(AVFormatContext *s)
325 328
{
326 329
    VideoData *img = s->priv_data;
330
    const char *str;
327 331

  
328 332
    img->img_number = 1;
329 333
    av_strlcpy(img->path, s->filename, sizeof(img->path));
......
334 338
    else
335 339
        img->is_pipe = 1;
336 340

  
341
    str = strrchr(img->path, '.');
342
    img->split_planes = str && !strcasecmp(str + 1, "y");
337 343
    return 0;
338 344
}
339 345

  
......
359 365
                return AVERROR(EIO);
360 366
            }
361 367

  
362
            if(codec->codec_id != CODEC_ID_RAWVIDEO)
368
            if(!img->split_planes)
363 369
                break;
364 370
            filename[ strlen(filename) - 1 ]= 'U' + i;
365 371
        }
......
367 373
        pb[0] = s->pb;
368 374
    }
369 375

  
370
    if(codec->codec_id == CODEC_ID_RAWVIDEO){
376
    if(img->split_planes){
371 377
        int ysize = codec->width * codec->height;
372 378
        avio_write(pb[0], pkt->data        , ysize);
373 379
        avio_write(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);

Also available in: Unified diff