comparison Plugins/Input/wma/libffwma/futils.c @ 210:12004b385a96 trunk

[svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
author chainsaw
date Sat, 19 Nov 2005 14:42:28 -0800
parents 5ce1d36e9ff5
children 0bea7509d6ba
comparison
equal deleted inserted replaced
209:bd8457b077cf 210:12004b385a96
14 * 14 *
15 * You should have received a copy of the GNU Lesser General Public 15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software 16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19
20 #include "avformat.h" 19 #include "avformat.h"
21 20
22 #undef NDEBUG 21 #undef NDEBUG
23 #include <assert.h> 22 #include <assert.h>
24 23
28 27
29 void av_register_input_format(AVInputFormat *format) 28 void av_register_input_format(AVInputFormat *format)
30 { 29 {
31 AVInputFormat **p; 30 AVInputFormat **p;
32 p = &first_iformat; 31 p = &first_iformat;
32 while (*p != NULL) p = &(*p)->next;
33 *p = format;
34 format->next = NULL;
35 }
36
37 void av_register_output_format(AVOutputFormat *format)
38 {
39 AVOutputFormat **p;
40 p = &first_oformat;
33 while (*p != NULL) p = &(*p)->next; 41 while (*p != NULL) p = &(*p)->next;
34 *p = format; 42 *p = format;
35 format->next = NULL; 43 format->next = NULL;
36 } 44 }
37 45
129 /** 137 /**
130 * Default packet destructor 138 * Default packet destructor
131 */ 139 */
132 static void av_destruct_packet(AVPacket *pkt) 140 static void av_destruct_packet(AVPacket *pkt)
133 { 141 {
134 free(pkt->data); 142 av_free(pkt->data);
135 pkt->data = NULL; pkt->size = 0; 143 pkt->data = NULL; pkt->size = 0;
136 } 144 }
137 145
138 /** 146 /**
139 * Allocate the payload of a packet and intialized its fields to default values. 147 * Allocate the payload of a packet and intialized its fields to default values.
140 * 148 *
142 * @param size wanted payload size 150 * @param size wanted payload size
143 * @return 0 if OK. AVERROR_xxx otherwise. 151 * @return 0 if OK. AVERROR_xxx otherwise.
144 */ 152 */
145 int av_new_packet(AVPacket *pkt, int size) 153 int av_new_packet(AVPacket *pkt, int size)
146 { 154 {
147 void *data = malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); 155 void *data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
148 if (!data) 156 if (!data)
149 return AVERROR_NOMEM; 157 return AVERROR_NOMEM;
150 memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); 158 memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
151 159
152 av_init_packet(pkt); 160 av_init_packet(pkt);
162 { 170 {
163 if (pkt->destruct != av_destruct_packet) { 171 if (pkt->destruct != av_destruct_packet) {
164 uint8_t *data; 172 uint8_t *data;
165 /* we duplicate the packet and don't forget to put the padding 173 /* we duplicate the packet and don't forget to put the padding
166 again */ 174 again */
167 data = malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE); 175 data = av_malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
168 if (!data) { 176 if (!data) {
169 return AVERROR_NOMEM; 177 return AVERROR_NOMEM;
170 } 178 }
171 memcpy(data, pkt->data, pkt->size); 179 memcpy(data, pkt->data, pkt->size);
172 memset(data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE); 180 memset(data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
178 186
179 /* fifo handling */ 187 /* fifo handling */
180 188
181 int fifo_init(FifoBuffer *f, int size) 189 int fifo_init(FifoBuffer *f, int size)
182 { 190 {
183 f->buffer = malloc(size); 191 f->buffer = av_malloc(size);
184 if (!f->buffer) 192 if (!f->buffer)
185 return -1; 193 return -1;
186 f->end = f->buffer + size; 194 f->end = f->buffer + size;
187 f->wptr = f->rptr = f->buffer; 195 f->wptr = f->rptr = f->buffer;
188 return 0; 196 return 0;
189 } 197 }
190 198
191 void fifo_free(FifoBuffer *f) 199 void fifo_free(FifoBuffer *f)
192 { 200 {
193 free(f->buffer); 201 av_free(f->buffer);
194 } 202 }
195 203
196 int fifo_size(FifoBuffer *f, uint8_t *rptr) 204 int fifo_size(FifoBuffer *f, uint8_t *rptr)
197 { 205 {
198 int size; 206 int size;
297 AVInputFormat *fmt, AVFormatParameters *ap) 305 AVInputFormat *fmt, AVFormatParameters *ap)
298 { 306 {
299 int err; 307 int err;
300 AVFormatContext *ic; 308 AVFormatContext *ic;
301 309
302 ic = malloc(sizeof(AVFormatContext)); 310 ic = av_mallocz(sizeof(AVFormatContext));
303 if (!ic) { 311 if (!ic) {
304 err = AVERROR_NOMEM; 312 err = AVERROR_NOMEM;
305 goto fail; 313 goto fail;
306 } 314 }
307 ic->iformat = fmt; 315 ic->iformat = fmt;
311 ic->start_time = AV_NOPTS_VALUE; 319 ic->start_time = AV_NOPTS_VALUE;
312 pstrcpy(ic->filename, sizeof(ic->filename), filename); 320 pstrcpy(ic->filename, sizeof(ic->filename), filename);
313 321
314 /* allocate private data */ 322 /* allocate private data */
315 if (fmt->priv_data_size > 0) { 323 if (fmt->priv_data_size > 0) {
316 ic->priv_data = malloc(fmt->priv_data_size); 324 ic->priv_data = av_mallocz(fmt->priv_data_size);
317 if (!ic->priv_data) { 325 if (!ic->priv_data) {
318 err = AVERROR_NOMEM; 326 err = AVERROR_NOMEM;
319 goto fail; 327 goto fail;
320 } 328 }
321 } else { 329 } else {
340 return 0; 348 return 0;
341 fail: 349 fail:
342 if (ic) { 350 if (ic) {
343 av_freep(&ic->priv_data); 351 av_freep(&ic->priv_data);
344 } 352 }
345 free(ic); 353 av_free(ic);
346 *ic_ptr = NULL; 354 *ic_ptr = NULL;
347 return err; 355 return err;
348 } 356 }
349 357
350 #define PROBE_BUF_SIZE 2048 358 #define PROBE_BUF_SIZE 2048
415 if (!fmt) { 423 if (!fmt) {
416 err = AVERROR_NOFMT; 424 err = AVERROR_NOFMT;
417 goto fail; 425 goto fail;
418 } 426 }
419 427
428 /* XXX: suppress this hack for redirectors */
429 #ifdef CONFIG_NETWORK
430 if (fmt == &redir_demux) {
431 err = redir_open(ic_ptr, pb);
432 url_fclose(pb);
433 return err;
434 }
435 #endif
436
420 /* check filename in case of an image number is expected */ 437 /* check filename in case of an image number is expected */
421 if (fmt->flags & AVFMT_NEEDNUMBER) { 438 if (fmt->flags & AVFMT_NEEDNUMBER) {
422 if (filename_number_test(filename) < 0) { 439 if (filename_number_test(filename) < 0) {
423 err = AVERROR_NUMEXPECTED; 440 err = AVERROR_NUMEXPECTED;
424 goto fail; 441 goto fail;
540 int frame_size; 557 int frame_size;
541 558
542 *pnum = 0; 559 *pnum = 0;
543 *pden = 0; 560 *pden = 0;
544 switch(st->codec.codec_type) { 561 switch(st->codec.codec_type) {
562 case CODEC_TYPE_VIDEO:
563 *pnum = st->codec.frame_rate_base;
564 *pden = st->codec.frame_rate;
565 if (pc && pc->repeat_pict) {
566 *pden *= 2;
567 *pnum = (*pnum) * (2 + pc->repeat_pict);
568 }
569 break;
545 case CODEC_TYPE_AUDIO: 570 case CODEC_TYPE_AUDIO:
546 frame_size = get_audio_frame_size(&st->codec, pkt->size); 571 frame_size = get_audio_frame_size(&st->codec, pkt->size);
547 if (frame_size < 0) 572 if (frame_size < 0)
548 break; 573 break;
549 *pnum = frame_size; 574 *pnum = frame_size;
566 } 591 }
567 } 592 }
568 593
569 /* do we have a video B frame ? */ 594 /* do we have a video B frame ? */
570 presentation_delayed = 0; 595 presentation_delayed = 0;
571 596 if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
597 /* XXX: need has_b_frame, but cannot get it if the codec is
598 not initialized */
599 if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO ||
600 st->codec.codec_id == CODEC_ID_MPEG2VIDEO ||
601 st->codec.codec_id == CODEC_ID_MPEG4 ||
602 st->codec.codec_id == CODEC_ID_H264) &&
603 pc && pc->pict_type != FF_B_TYPE)
604 presentation_delayed = 1;
605 }
606
572 /* interpolate PTS and DTS if they are not present */ 607 /* interpolate PTS and DTS if they are not present */
573 if (presentation_delayed) { 608 if (presentation_delayed) {
574 /* DTS = decompression time stamp */ 609 /* DTS = decompression time stamp */
575 /* PTS = presentation time stamp */ 610 /* PTS = presentation time stamp */
576 if (pkt->dts == AV_NOPTS_VALUE) { 611 if (pkt->dts == AV_NOPTS_VALUE) {
600 } 635 }
601 636
602 /* update flags */ 637 /* update flags */
603 if (pc) { 638 if (pc) {
604 pkt->flags = 0; 639 pkt->flags = 0;
605 /* XXX: that's odd, fix it later */ 640 /* key frame computation */
606 switch(st->codec.codec_type) { 641 switch(st->codec.codec_type) {
642 case CODEC_TYPE_VIDEO:
643 if (pc->pict_type == FF_I_TYPE)
644 pkt->flags |= PKT_FLAG_KEY;
645 break;
607 case CODEC_TYPE_AUDIO: 646 case CODEC_TYPE_AUDIO:
608 pkt->flags |= PKT_FLAG_KEY; 647 pkt->flags |= PKT_FLAG_KEY;
609 break; 648 break;
610 default: 649 default:
611 break; 650 break;
748 pktl = s->packet_buffer; 787 pktl = s->packet_buffer;
749 if (pktl) { 788 if (pktl) {
750 /* read packet from packet buffer, if there is data */ 789 /* read packet from packet buffer, if there is data */
751 *pkt = pktl->pkt; 790 *pkt = pktl->pkt;
752 s->packet_buffer = pktl->next; 791 s->packet_buffer = pktl->next;
753 free(pktl); 792 av_free(pktl);
754 return 0; 793 return 0;
755 } else { 794 } else {
756 return av_read_frame_internal(s, pkt); 795 return av_read_frame_internal(s, pkt);
757 } 796 }
758 } 797 }
766 pktl = s->packet_buffer; 805 pktl = s->packet_buffer;
767 if (!pktl) 806 if (!pktl)
768 break; 807 break;
769 s->packet_buffer = pktl->next; 808 s->packet_buffer = pktl->next;
770 av_free_packet(&pktl->pkt); 809 av_free_packet(&pktl->pkt);
771 free(pktl); 810 av_free(pktl);
772 } 811 }
773 } 812 }
774 813
775 /*******************************************************/ 814 /*******************************************************/
776 /* seek support */ 815 /* seek support */
782 821
783 if (s->nb_streams <= 0) 822 if (s->nb_streams <= 0)
784 return -1; 823 return -1;
785 for(i = 0; i < s->nb_streams; i++) { 824 for(i = 0; i < s->nb_streams; i++) {
786 st = s->streams[i]; 825 st = s->streams[i];
787 826 if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
827 return i;
828 }
788 } 829 }
789 return 0; 830 return 0;
790 } 831 }
791 832
792 /* flush the frame reader */ 833 /* flush the frame reader */
825 { 866 {
826 AVIndexEntry *entries, *ie; 867 AVIndexEntry *entries, *ie;
827 int index; 868 int index;
828 869
829 entries = av_fast_realloc(st->index_entries, 870 entries = av_fast_realloc(st->index_entries,
830 &st->index_entries_allocated_size, 871 (unsigned int*)&st->index_entries_allocated_size,
831 (st->nb_index_entries + 1) * 872 (st->nb_index_entries + 1) *
832 sizeof(AVIndexEntry)); 873 sizeof(AVIndexEntry));
833 st->index_entries= entries; 874 st->index_entries= entries;
834 875
835 if(st->nb_index_entries){ 876 if(st->nb_index_entries){
1273 int val; 1314 int val;
1274 switch(enc->codec_type) { 1315 switch(enc->codec_type) {
1275 case CODEC_TYPE_AUDIO: 1316 case CODEC_TYPE_AUDIO:
1276 val = enc->sample_rate; 1317 val = enc->sample_rate;
1277 break; 1318 break;
1319 case CODEC_TYPE_VIDEO:
1320 val = enc->width;
1321 break;
1278 default: 1322 default:
1279 val = 1; 1323 val = 1;
1280 break; 1324 break;
1281 } 1325 }
1282 return (val != 0); 1326 return (val != 0);
1285 static int try_decode_frame(AVStream *st, const uint8_t *data, int size) 1329 static int try_decode_frame(AVStream *st, const uint8_t *data, int size)
1286 { 1330 {
1287 int16_t *samples; 1331 int16_t *samples;
1288 AVCodec *codec; 1332 AVCodec *codec;
1289 int got_picture, ret; 1333 int got_picture, ret;
1334 AVFrame picture;
1290 1335
1291 codec = avcodec_find_decoder(st->codec.codec_id); 1336 codec = avcodec_find_decoder(st->codec.codec_id);
1292 if (!codec) 1337 if (!codec)
1293 return -1; 1338 return -1;
1294 ret = avcodec_open(&st->codec, codec); 1339 ret = avcodec_open(&st->codec, codec);
1295 if (ret < 0) 1340 if (ret < 0)
1296 return ret; 1341 return ret;
1297 switch(st->codec.codec_type) { 1342 switch(st->codec.codec_type) {
1298 case CODEC_TYPE_AUDIO: 1343 case CODEC_TYPE_VIDEO:
1299 samples = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); 1344 ret = avcodec_decode_video(&st->codec, &picture,
1300 if (!samples)
1301 goto fail;
1302
1303 ret = avcodec_decode_audio(&st->codec, samples,
1304 &got_picture, (uint8_t *)data, size); 1345 &got_picture, (uint8_t *)data, size);
1305 free(samples); 1346 break;
1306 1347 case CODEC_TYPE_AUDIO:
1307 break; 1348 samples = av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
1308 default: 1349 if (!samples)
1309 break; 1350 goto fail;
1351 ret = avcodec_decode_audio(&st->codec, samples,
1352 &got_picture, (uint8_t *)data, size);
1353 av_free(samples);
1354 break;
1355 default:
1356 break;
1310 } 1357 }
1311 fail: 1358 fail:
1312 avcodec_close(&st->codec); 1359 avcodec_close(&st->codec);
1313 return ret; 1360 return ret;
1314 } 1361 }
1373 i == ic->nb_streams) 1420 i == ic->nb_streams)
1374 ret = 0; 1421 ret = 0;
1375 break; 1422 break;
1376 } 1423 }
1377 1424
1378 pktl = malloc(sizeof(AVPacketList)); 1425 pktl = av_mallocz(sizeof(AVPacketList));
1379 if (!pktl) { 1426 if (!pktl) {
1380 ret = AVERROR_NOMEM; 1427 ret = AVERROR_NOMEM;
1381 break; 1428 break;
1382 } 1429 }
1383 1430
1403 1450
1404 /* if still no information, we try to open the codec and to 1451 /* if still no information, we try to open the codec and to
1405 decompress the frame. We try to avoid that in most cases as 1452 decompress the frame. We try to avoid that in most cases as
1406 it takes longer and uses more memory. For MPEG4, we need to 1453 it takes longer and uses more memory. For MPEG4, we need to
1407 decompress for Quicktime. */ 1454 decompress for Quicktime. */
1455 if (!has_codec_parameters(&st->codec) &&
1456 (st->codec.codec_id == CODEC_ID_FLV1 ||
1457 st->codec.codec_id == CODEC_ID_H264 ||
1458 st->codec.codec_id == CODEC_ID_H263 ||
1459 (st->codec.codec_id == CODEC_ID_MPEG4 && !st->need_parsing)))
1460 try_decode_frame(st, pkt->data, pkt->size);
1461
1408 if (st->codec_info_duration >= MAX_STREAM_DURATION) { 1462 if (st->codec_info_duration >= MAX_STREAM_DURATION) {
1409 break; 1463 break;
1410 } 1464 }
1411 count++; 1465 count++;
1412 } 1466 }
1413 1467
1414 /* set real frame rate info */ 1468 /* set real frame rate info */
1415 for(i=0;i<ic->nb_streams;i++) { 1469 for(i=0;i<ic->nb_streams;i++) {
1416 st = ic->streams[i]; 1470 st = ic->streams[i];
1471 if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
1472 /* compute the real frame rate for telecine */
1473 if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO ||
1474 st->codec.codec_id == CODEC_ID_MPEG2VIDEO) &&
1475 st->codec.sub_id == 2) {
1476 if (st->codec_info_nb_frames >= 20) {
1477 float coded_frame_rate, est_frame_rate;
1478 est_frame_rate = ((double)st->codec_info_nb_frames * AV_TIME_BASE) /
1479 (double)st->codec_info_duration ;
1480 coded_frame_rate = (double)st->codec.frame_rate /
1481 (double)st->codec.frame_rate_base;
1482 #if 0
1483 printf("telecine: coded_frame_rate=%0.3f est_frame_rate=%0.3f\n",
1484 coded_frame_rate, est_frame_rate);
1485 #endif
1486 /* if we detect that it could be a telecine, we
1487 signal it. It would be better to do it at a
1488 higher level as it can change in a film */
1489 if (coded_frame_rate >= 24.97 &&
1490 (est_frame_rate >= 23.5 && est_frame_rate < 24.5)) {
1491 st->r_frame_rate = 24024;
1492 st->r_frame_rate_base = 1001;
1493 }
1494 }
1495 }
1496 /* if no real frame rate, use the codec one */
1497 if (!st->r_frame_rate){
1498 st->r_frame_rate = st->codec.frame_rate;
1499 st->r_frame_rate_base = st->codec.frame_rate_base;
1500 }
1501 }
1417 } 1502 }
1418 1503
1419 av_estimate_timings(ic); 1504 av_estimate_timings(ic);
1420 return ret; 1505 return ret;
1421 } 1506 }
1464 /* free all data in a stream component */ 1549 /* free all data in a stream component */
1465 st = s->streams[i]; 1550 st = s->streams[i];
1466 if (st->parser) { 1551 if (st->parser) {
1467 av_parser_close(st->parser); 1552 av_parser_close(st->parser);
1468 } 1553 }
1469 free(st->index_entries); 1554 av_free(st->index_entries);
1470 free(st); 1555 av_free(st);
1471 } 1556 }
1472 flush_packet_queue(s); 1557 flush_packet_queue(s);
1473 must_open_file = 1; 1558 must_open_file = 1;
1474 if (s->iformat->flags & AVFMT_NOFILE) { 1559 if (s->iformat->flags & AVFMT_NOFILE) {
1475 must_open_file = 0; 1560 must_open_file = 0;
1476 } 1561 }
1477 if (must_open_file) { 1562 if (must_open_file) {
1478 url_fclose(&s->pb); 1563 url_fclose(&s->pb);
1479 } 1564 }
1480 av_freep(&s->priv_data); 1565 av_freep(&s->priv_data);
1481 free(s); 1566 av_free(s);
1482 } 1567 }
1483 1568
1484 /** 1569 /**
1485 * Add a new stream to a media file. Can only be called in the 1570 * Add a new stream to a media file. Can only be called in the
1486 * read_header function. If the flag AVFMTCTX_NOHEADER is in the 1571 * read_header function. If the flag AVFMTCTX_NOHEADER is in the
1495 AVStream *st; 1580 AVStream *st;
1496 1581
1497 if (s->nb_streams >= MAX_STREAMS) 1582 if (s->nb_streams >= MAX_STREAMS)
1498 return NULL; 1583 return NULL;
1499 1584
1500 #if 0 1585 st = av_mallocz(sizeof(AVStream));
1501 /* we shouldn't have to do this but ffmpeg sucks --nenolod */
1502 *s->streams = malloc(sizeof(AVStream *) * s->nb_streams);
1503 #endif
1504
1505 st = malloc(sizeof(AVStream));
1506 if (!st) 1586 if (!st)
1507 return NULL; 1587 return NULL;
1508 avcodec_get_context_defaults(&st->codec); 1588 avcodec_get_context_defaults(&st->codec);
1509 if (s->iformat) { 1589 if (s->iformat) {
1510 /* no default bitrate if decoding */ 1590 /* no default bitrate if decoding */
1512 } 1592 }
1513 st->index = s->nb_streams; 1593 st->index = s->nb_streams;
1514 st->id = id; 1594 st->id = id;
1515 st->start_time = AV_NOPTS_VALUE; 1595 st->start_time = AV_NOPTS_VALUE;
1516 st->duration = AV_NOPTS_VALUE; 1596 st->duration = AV_NOPTS_VALUE;
1517 s->streams[st->index] = st; 1597 s->streams[s->nb_streams++] = st;
1518 s->nb_streams++; // WTF?
1519 return st; 1598 return st;
1520 } 1599 }
1521 1600
1522 /************************************************************/ 1601 /************************************************************/
1523 /* output media file */ 1602 /* output media file */
1525 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap) 1604 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
1526 { 1605 {
1527 int ret; 1606 int ret;
1528 1607
1529 if (s->oformat->priv_data_size > 0) { 1608 if (s->oformat->priv_data_size > 0) {
1530 s->priv_data = malloc(s->oformat->priv_data_size); 1609 s->priv_data = av_mallocz(s->oformat->priv_data_size);
1531 if (!s->priv_data) 1610 if (!s->priv_data)
1532 return AVERROR_NOMEM; 1611 return AVERROR_NOMEM;
1533 } else 1612 } else
1534 s->priv_data = NULL; 1613 s->priv_data = NULL;
1535 1614
1565 1644
1566 switch (st->codec.codec_type) { 1645 switch (st->codec.codec_type) {
1567 case CODEC_TYPE_AUDIO: 1646 case CODEC_TYPE_AUDIO:
1568 av_frac_init(&st->pts, 0, 0, 1647 av_frac_init(&st->pts, 0, 0,
1569 (int64_t)s->pts_num * st->codec.sample_rate); 1648 (int64_t)s->pts_num * st->codec.sample_rate);
1649 break;
1650 case CODEC_TYPE_VIDEO:
1651 av_frac_init(&st->pts, 0, 0,
1652 (int64_t)s->pts_num * st->codec.frame_rate);
1570 break; 1653 break;
1571 default: 1654 default:
1572 break; 1655 break;
1573 } 1656 }
1574 } 1657 }
1605 frame_size = get_audio_frame_size(&st->codec, size); 1688 frame_size = get_audio_frame_size(&st->codec, size);
1606 if (frame_size >= 0) { 1689 if (frame_size >= 0) {
1607 av_frac_add(&st->pts, 1690 av_frac_add(&st->pts,
1608 (int64_t)s->pts_den * frame_size); 1691 (int64_t)s->pts_den * frame_size);
1609 } 1692 }
1693 break;
1694 case CODEC_TYPE_VIDEO:
1695 av_frac_add(&st->pts,
1696 (int64_t)s->pts_den * st->codec.frame_rate_base);
1610 break; 1697 break;
1611 default: 1698 default:
1612 break; 1699 break;
1613 } 1700 }
1614 return ret; 1701 return ret;
2211 */ 2298 */
2212 int av_read_image(ByteIOContext *pb, const char *filename, 2299 int av_read_image(ByteIOContext *pb, const char *filename,
2213 AVImageFormat *fmt, 2300 AVImageFormat *fmt,
2214 int (*alloc_cb)(void *, AVImageInfo *info), void *opaque) 2301 int (*alloc_cb)(void *, AVImageInfo *info), void *opaque)
2215 { 2302 {
2216 char buf[PROBE_BUF_SIZE]; 2303 unsigned char buf[PROBE_BUF_SIZE];
2217 AVProbeData probe_data, *pd = &probe_data; 2304 AVProbeData probe_data, *pd = &probe_data;
2218 offset_t pos; 2305 offset_t pos;
2219 int ret; 2306 int ret;
2220 2307
2221 if (!fmt) { 2308 if (!fmt) {