Revision 01f4895c libavformat/yuv4mpeg.c

View differences:

libavformat/yuv4mpeg.c
33 33
    char *colorspace = "";
34 34

  
35 35
    st = s->streams[0];
36
    width = st->codec.width;
37
    height = st->codec.height;
36
    width = st->codec->width;
37
    height = st->codec->height;
38 38

  
39
    av_reduce(&raten, &rated, st->codec.time_base.den, st->codec.time_base.num, (1UL<<31)-1);
39
    av_reduce(&raten, &rated, st->codec->time_base.den, st->codec->time_base.num, (1UL<<31)-1);
40 40
    
41
    aspectn = st->codec.sample_aspect_ratio.num;
42
    aspectd = st->codec.sample_aspect_ratio.den;
41
    aspectn = st->codec->sample_aspect_ratio.num;
42
    aspectd = st->codec->sample_aspect_ratio.den;
43 43
    
44 44
    if ( aspectn == 0 && aspectd == 1 ) aspectd = 0;  // 0:0 means unknown
45 45

  
46 46
    inter = 'p'; /* progressive is the default */
47
    if (st->codec.coded_frame && st->codec.coded_frame->interlaced_frame) {
48
        inter = st->codec.coded_frame->top_field_first ? 't' : 'b';
47
    if (st->codec->coded_frame && st->codec->coded_frame->interlaced_frame) {
48
        inter = st->codec->coded_frame->top_field_first ? 't' : 'b';
49 49
    }
50 50

  
51
    switch(st->codec.pix_fmt) {
51
    switch(st->codec->pix_fmt) {
52 52
    case PIX_FMT_GRAY8:
53 53
        colorspace = " Cmono";
54 54
        break;
......
56 56
        colorspace = " C411 XYSCSS=411";
57 57
        break;
58 58
    case PIX_FMT_YUV420P:
59
        colorspace = (st->codec.codec_id == CODEC_ID_DVVIDEO)?" C420paldv XYSCSS=420PALDV":" C420mpeg2 XYSCSS=420MPEG2";
59
        colorspace = (st->codec->codec_id == CODEC_ID_DVVIDEO)?" C420paldv XYSCSS=420PALDV":" C420mpeg2 XYSCSS=420MPEG2";
60 60
        break;
61 61
    case PIX_FMT_YUV422P:
62 62
        colorspace = " C422 XYSCSS=422";
......
109 109
    m = snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC);
110 110
    put_buffer(pb, buf1, strlen(buf1));
111 111

  
112
    width = st->codec.width;
113
    height = st->codec.height;
112
    width = st->codec->width;
113
    height = st->codec->height;
114 114
    
115 115
    ptr = picture->data[0];
116 116
    for(i=0;i<height;i++) {
......
118 118
        ptr += picture->linesize[0];
119 119
    }
120 120

  
121
    if (st->codec.pix_fmt != PIX_FMT_GRAY8){
121
    if (st->codec->pix_fmt != PIX_FMT_GRAY8){
122 122
    // Adjust for smaller Cb and Cr planes
123
    avcodec_get_chroma_sub_sample(st->codec.pix_fmt, &h_chroma_shift, &v_chroma_shift);
123
    avcodec_get_chroma_sub_sample(st->codec->pix_fmt, &h_chroma_shift, &v_chroma_shift);
124 124
    width >>= h_chroma_shift;
125 125
    height >>= v_chroma_shift;
126 126

  
......
146 146
    if (s->nb_streams != 1)
147 147
        return AVERROR_IO;
148 148
    
149
    if (s->streams[0]->codec.pix_fmt == PIX_FMT_YUV411P) {
149
    if (s->streams[0]->codec->pix_fmt == PIX_FMT_YUV411P) {
150 150
        av_log(s, AV_LOG_ERROR, "Warning: generating rarely used 4:1:1 YUV stream, some mjpegtools might not work.\n");
151 151
    } 
152
    else if ((s->streams[0]->codec.pix_fmt != PIX_FMT_YUV420P) && 
153
             (s->streams[0]->codec.pix_fmt != PIX_FMT_YUV422P) && 
154
             (s->streams[0]->codec.pix_fmt != PIX_FMT_GRAY8) && 
155
             (s->streams[0]->codec.pix_fmt != PIX_FMT_YUV444P)) {
152
    else if ((s->streams[0]->codec->pix_fmt != PIX_FMT_YUV420P) && 
153
             (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV422P) && 
154
             (s->streams[0]->codec->pix_fmt != PIX_FMT_GRAY8) && 
155
             (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV444P)) {
156 156
        av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles yuv444p, yuv422p, yuv420p, yuv411p and gray pixel formats. Use -pix_fmt to select one.\n");
157 157
	return AVERROR_IO;
158 158
    }
......
320 320
        
321 321
    st = av_new_stream(s, 0);
322 322
    st = s->streams[0];
323
    st->codec.width = width;
324
    st->codec.height = height;
323
    st->codec->width = width;
324
    st->codec->height = height;
325 325
    av_reduce(&raten, &rated, raten, rated, (1UL<<31)-1);
326 326
    av_set_pts_info(st, 64, rated, raten);
327
    st->codec.pix_fmt = pix_fmt;
328
    st->codec.codec_type = CODEC_TYPE_VIDEO;
329
    st->codec.codec_id = CODEC_ID_RAWVIDEO;
330
    st->codec.sample_aspect_ratio= (AVRational){aspectn, aspectd};
327
    st->codec->pix_fmt = pix_fmt;
328
    st->codec->codec_type = CODEC_TYPE_VIDEO;
329
    st->codec->codec_id = CODEC_ID_RAWVIDEO;
330
    st->codec->sample_aspect_ratio= (AVRational){aspectn, aspectd};
331 331

  
332 332
    return 0;
333 333
}
......
349 349
    if (i == MAX_FRAME_HEADER) return -1;
350 350
    if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) return -1;
351 351
    
352
    width = st->codec.width;
353
    height = st->codec.height;
352
    width = st->codec->width;
353
    height = st->codec->height;
354 354

  
355
    packet_size = avpicture_get_size(st->codec.pix_fmt, width, height);
355
    packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
356 356
    if (packet_size < 0)
357 357
        return -1;
358 358

  

Also available in: Unified diff