comparison rmdec.c @ 2291:8f90908f3c31 libavformat

Merge get_str() and get_str8() functions. patch by Ronald S. Bultje, rsbultje gmail com
author diego
date Sat, 28 Jul 2007 18:05:11 +0000
parents 572f7077ba40
children 5faceca0b5d6
comparison
equal deleted inserted replaced
2290:572f7077ba40 2291:8f90908f3c31
20 */ 20 */
21 #include "avformat.h" 21 #include "avformat.h"
22 #include "rm.h" 22 #include "rm.h"
23 #include "avstring.h" 23 #include "avstring.h"
24 24
25 static void get_str(ByteIOContext *pb, char *buf, int buf_size) 25 static inline void get_strl(ByteIOContext *pb, char *buf, int buf_size, int len)
26 { 26 {
27 int len, i; 27 int i;
28 char *q, r; 28 char *q, r;
29 29
30 len = get_be16(pb);
31 q = buf; 30 q = buf;
32 for(i=0;i<len;i++) { 31 for(i=0;i<len;i++) {
33 r = get_byte(pb); 32 r = get_byte(pb);
34 if (i < buf_size - 1) 33 if (i < buf_size - 1)
35 *q++ = r; 34 *q++ = r;
36 } 35 }
37 if (buf_size > 0) *q = '\0'; 36 if (buf_size > 0) *q = '\0';
38 } 37 }
39 38
39 static void get_str16(ByteIOContext *pb, char *buf, int buf_size)
40 {
41 get_strl(pb, buf, buf_size, get_be16(pb));
42 }
43
40 static void get_str8(ByteIOContext *pb, char *buf, int buf_size) 44 static void get_str8(ByteIOContext *pb, char *buf, int buf_size)
41 { 45 {
42 int len, i; 46 get_strl(pb, buf, buf_size, get_byte(pb));
43 char *q, r;
44
45 len = get_byte(pb);
46 q = buf;
47 for(i=0;i<len;i++) {
48 r = get_byte(pb);
49 if (i < buf_size - 1)
50 *q++ = r;
51 }
52 if (buf_size > 0) *q = '\0';
53 } 47 }
54 48
55 static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, 49 static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st,
56 int read_all) 50 int read_all)
57 { 51 {
261 get_be32(pb); /* data offset */ 255 get_be32(pb); /* data offset */
262 get_be16(pb); /* nb streams */ 256 get_be16(pb); /* nb streams */
263 flags = get_be16(pb); /* flags */ 257 flags = get_be16(pb); /* flags */
264 break; 258 break;
265 case MKTAG('C', 'O', 'N', 'T'): 259 case MKTAG('C', 'O', 'N', 'T'):
266 get_str(pb, s->title, sizeof(s->title)); 260 get_str16(pb, s->title, sizeof(s->title));
267 get_str(pb, s->author, sizeof(s->author)); 261 get_str16(pb, s->author, sizeof(s->author));
268 get_str(pb, s->copyright, sizeof(s->copyright)); 262 get_str16(pb, s->copyright, sizeof(s->copyright));
269 get_str(pb, s->comment, sizeof(s->comment)); 263 get_str16(pb, s->comment, sizeof(s->comment));
270 break; 264 break;
271 case MKTAG('M', 'D', 'P', 'R'): 265 case MKTAG('M', 'D', 'P', 'R'):
272 st = av_new_stream(s, 0); 266 st = av_new_stream(s, 0);
273 if (!st) 267 if (!st)
274 goto fail; 268 goto fail;