comparison yuv4mpeg.c @ 2771:d52c718e83f9 libavformat

Use dynamically allocated ByteIOContext in AVFormatContext patch by: Bj«Órn Axelsson, bjorn d axelsson a intinor d se thread: [PATCH] Remove static ByteIOContexts, 06 nov 2007
author andoma
date Wed, 21 Nov 2007 07:41:00 +0000
parents b21c2af60bc9
children 2d7d35d04f9c
comparison
equal deleted inserted replaced
2770:a7e42cf4b364 2771:d52c718e83f9
85 } 85 }
86 86
87 static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) 87 static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
88 { 88 {
89 AVStream *st = s->streams[pkt->stream_index]; 89 AVStream *st = s->streams[pkt->stream_index];
90 ByteIOContext *pb = &s->pb; 90 ByteIOContext *pb = s->pb;
91 AVPicture *picture; 91 AVPicture *picture;
92 int* first_pkt = s->priv_data; 92 int* first_pkt = s->priv_data;
93 int width, height, h_chroma_shift, v_chroma_shift; 93 int width, height, h_chroma_shift, v_chroma_shift;
94 int i, m; 94 int i, m;
95 char buf2[Y4M_LINE_MAX+1]; 95 char buf2[Y4M_LINE_MAX+1];
188 static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap) 188 static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap)
189 { 189 {
190 char header[MAX_YUV4_HEADER+10]; // Include headroom for the longest option 190 char header[MAX_YUV4_HEADER+10]; // Include headroom for the longest option
191 char *tokstart,*tokend,*header_end; 191 char *tokstart,*tokend,*header_end;
192 int i; 192 int i;
193 ByteIOContext *pb = &s->pb; 193 ByteIOContext *pb = s->pb;
194 int width=-1, height=-1, raten=0, rated=0, aspectn=0, aspectd=0; 194 int width=-1, height=-1, raten=0, rated=0, aspectn=0, aspectd=0;
195 enum PixelFormat pix_fmt=PIX_FMT_NONE,alt_pix_fmt=PIX_FMT_NONE; 195 enum PixelFormat pix_fmt=PIX_FMT_NONE,alt_pix_fmt=PIX_FMT_NONE;
196 AVStream *st; 196 AVStream *st;
197 struct frame_attributes *s1 = s->priv_data; 197 struct frame_attributes *s1 = s->priv_data;
198 198
342 int packet_size, width, height; 342 int packet_size, width, height;
343 AVStream *st = s->streams[0]; 343 AVStream *st = s->streams[0];
344 struct frame_attributes *s1 = s->priv_data; 344 struct frame_attributes *s1 = s->priv_data;
345 345
346 for (i=0; i<MAX_FRAME_HEADER; i++) { 346 for (i=0; i<MAX_FRAME_HEADER; i++) {
347 header[i] = get_byte(&s->pb); 347 header[i] = get_byte(s->pb);
348 if (header[i] == '\n') { 348 if (header[i] == '\n') {
349 header[i+1] = 0; 349 header[i+1] = 0;
350 break; 350 break;
351 } 351 }
352 } 352 }
358 358
359 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height); 359 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
360 if (packet_size < 0) 360 if (packet_size < 0)
361 return -1; 361 return -1;
362 362
363 if (av_get_packet(&s->pb, pkt, packet_size) != packet_size) 363 if (av_get_packet(s->pb, pkt, packet_size) != packet_size)
364 return AVERROR(EIO); 364 return AVERROR(EIO);
365 365
366 if (s->streams[0]->codec->coded_frame) { 366 if (s->streams[0]->codec->coded_frame) {
367 s->streams[0]->codec->coded_frame->interlaced_frame = s1->interlaced_frame; 367 s->streams[0]->codec->coded_frame->interlaced_frame = s1->interlaced_frame;
368 s->streams[0]->codec->coded_frame->top_field_first = s1->top_field_first; 368 s->streams[0]->codec->coded_frame->top_field_first = s1->top_field_first;