OLD | NEW |
1 /* | 1 /* |
2 * Matroska file demuxer | 2 * Matroska file demuxer |
3 * Copyright (c) 2003-2008 The FFmpeg Project | 3 * Copyright (c) 2003-2008 The FFmpeg Project |
4 * | 4 * |
5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
6 * | 6 * |
7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 avio_wl16(&b, track->audio.channels); | 1560 avio_wl16(&b, track->audio.channels); |
1561 avio_wl16(&b, track->audio.bitdepth); | 1561 avio_wl16(&b, track->audio.bitdepth); |
1562 avio_wl32(&b, track->audio.out_samplerate); | 1562 avio_wl32(&b, track->audio.out_samplerate); |
1563 avio_wl32(&b, matroska->ctx->duration * track->audio.out_samplerate)
; | 1563 avio_wl32(&b, matroska->ctx->duration * track->audio.out_samplerate)
; |
1564 } else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 || | 1564 } else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 || |
1565 codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) { | 1565 codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) { |
1566 extradata_offset = 26; | 1566 extradata_offset = 26; |
1567 } else if (codec_id == CODEC_ID_RA_144) { | 1567 } else if (codec_id == CODEC_ID_RA_144) { |
1568 track->audio.out_samplerate = 8000; | 1568 track->audio.out_samplerate = 8000; |
1569 track->audio.channels = 1; | 1569 track->audio.channels = 1; |
1570 } else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK || | 1570 } |
| 1571 #if CONFIG_RA_288_DECODER || CONFIG_COOK_DECODER || CONFIG_ATRAC3_DECODER || CON
FIG_SIPR_DECODER |
| 1572 else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK || |
1571 codec_id == CODEC_ID_ATRAC3 || codec_id == CODEC_ID_SIPR) { | 1573 codec_id == CODEC_ID_ATRAC3 || codec_id == CODEC_ID_SIPR) { |
1572 int flavor; | 1574 int flavor; |
1573 ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size, | 1575 ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size, |
1574 0, NULL, NULL, NULL, NULL); | 1576 0, NULL, NULL, NULL, NULL); |
1575 avio_skip(&b, 22); | 1577 avio_skip(&b, 22); |
1576 flavor = avio_rb16(&b); | 1578 flavor = avio_rb16(&b); |
1577 track->audio.coded_framesize = avio_rb32(&b); | 1579 track->audio.coded_framesize = avio_rb32(&b); |
1578 avio_skip(&b, 12); | 1580 avio_skip(&b, 12); |
1579 track->audio.sub_packet_h = avio_rb16(&b); | 1581 track->audio.sub_packet_h = avio_rb16(&b); |
1580 track->audio.frame_size = avio_rb16(&b); | 1582 track->audio.frame_size = avio_rb16(&b); |
1581 track->audio.sub_packet_size = avio_rb16(&b); | 1583 track->audio.sub_packet_size = avio_rb16(&b); |
1582 track->audio.buf = av_malloc(track->audio.frame_size * track->audio.
sub_packet_h); | 1584 track->audio.buf = av_malloc(track->audio.frame_size * track->audio.
sub_packet_h); |
1583 if (codec_id == CODEC_ID_RA_288) { | 1585 if (codec_id == CODEC_ID_RA_288) { |
1584 st->codec->block_align = track->audio.coded_framesize; | 1586 st->codec->block_align = track->audio.coded_framesize; |
1585 track->codec_priv.size = 0; | 1587 track->codec_priv.size = 0; |
1586 } else { | 1588 } else { |
1587 #if CONFIG_SIPR_DECODER | 1589 #if CONFIG_SIPR_DECODER |
1588 if (codec_id == CODEC_ID_SIPR && flavor < 4) { | 1590 if (codec_id == CODEC_ID_SIPR && flavor < 4) { |
1589 const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 }; | 1591 const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 }; |
1590 track->audio.sub_packet_size = ff_sipr_subpk_size[flavor]; | 1592 track->audio.sub_packet_size = ff_sipr_subpk_size[flavor]; |
1591 st->codec->bit_rate = sipr_bit_rate[flavor]; | 1593 st->codec->bit_rate = sipr_bit_rate[flavor]; |
1592 } | 1594 } |
1593 #endif | 1595 #endif |
1594 st->codec->block_align = track->audio.sub_packet_size; | 1596 st->codec->block_align = track->audio.sub_packet_size; |
1595 extradata_offset = 78; | 1597 extradata_offset = 78; |
1596 } | 1598 } |
1597 } | 1599 } |
| 1600 #endif |
1598 track->codec_priv.size -= extradata_offset; | 1601 track->codec_priv.size -= extradata_offset; |
1599 | 1602 |
1600 if (codec_id == CODEC_ID_NONE) | 1603 if (codec_id == CODEC_ID_NONE) |
1601 av_log(matroska->ctx, AV_LOG_INFO, | 1604 av_log(matroska->ctx, AV_LOG_INFO, |
1602 "Unknown/unsupported CodecID %s.\n", track->codec_id); | 1605 "Unknown/unsupported CodecID %s.\n", track->codec_id); |
1603 | 1606 |
1604 if (track->time_scale < 0.01) | 1607 if (track->time_scale < 0.01) |
1605 track->time_scale = 1.0; | 1608 track->time_scale = 1.0; |
1606 avpriv_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000
*1000*1000); /* 64 bit pts in ns */ | 1609 avpriv_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000
*1000*1000); /* 64 bit pts in ns */ |
1607 | 1610 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 } | 1908 } |
1906 lace_size[laces - 1] = size - total; | 1909 lace_size[laces - 1] = size - total; |
1907 break; | 1910 break; |
1908 } | 1911 } |
1909 } | 1912 } |
1910 break; | 1913 break; |
1911 } | 1914 } |
1912 | 1915 |
1913 if (res == 0) { | 1916 if (res == 0) { |
1914 for (n = 0; n < laces; n++) { | 1917 for (n = 0; n < laces; n++) { |
| 1918 #if CONFIG_RA_288_DECODER || CONFIG_COOK_DECODER || CONFIG_ATRAC3_DECODER || CON
FIG_SIPR_DECODER |
1915 if ((st->codec->codec_id == CODEC_ID_RA_288 || | 1919 if ((st->codec->codec_id == CODEC_ID_RA_288 || |
1916 st->codec->codec_id == CODEC_ID_COOK || | 1920 st->codec->codec_id == CODEC_ID_COOK || |
1917 st->codec->codec_id == CODEC_ID_SIPR || | 1921 st->codec->codec_id == CODEC_ID_SIPR || |
1918 st->codec->codec_id == CODEC_ID_ATRAC3) && | 1922 st->codec->codec_id == CODEC_ID_ATRAC3) && |
1919 st->codec->block_align && track->audio.sub_packet_size) { | 1923 st->codec->block_align && track->audio.sub_packet_size) { |
1920 int a = st->codec->block_align; | 1924 int a = st->codec->block_align; |
1921 int sps = track->audio.sub_packet_size; | 1925 int sps = track->audio.sub_packet_size; |
1922 int cfs = track->audio.coded_framesize; | 1926 int cfs = track->audio.coded_framesize; |
1923 int h = track->audio.sub_packet_h; | 1927 int h = track->audio.sub_packet_h; |
1924 int y = track->audio.sub_packet_cnt; | 1928 int y = track->audio.sub_packet_cnt; |
(...skipping 26 matching lines...) Expand all Loading... |
1951 pkt = av_mallocz(sizeof(AVPacket)); | 1955 pkt = av_mallocz(sizeof(AVPacket)); |
1952 av_new_packet(pkt, a); | 1956 av_new_packet(pkt, a); |
1953 memcpy(pkt->data, track->audio.buf | 1957 memcpy(pkt->data, track->audio.buf |
1954 + a * (h*w / a - track->audio.pkt_cnt--), a); | 1958 + a * (h*w / a - track->audio.pkt_cnt--), a); |
1955 pkt->pts = track->audio.buf_timecode; | 1959 pkt->pts = track->audio.buf_timecode; |
1956 track->audio.buf_timecode = AV_NOPTS_VALUE; | 1960 track->audio.buf_timecode = AV_NOPTS_VALUE; |
1957 pkt->pos = pos; | 1961 pkt->pos = pos; |
1958 pkt->stream_index = st->index; | 1962 pkt->stream_index = st->index; |
1959 dynarray_add(&matroska->packets,&matroska->num_packets,pkt); | 1963 dynarray_add(&matroska->packets,&matroska->num_packets,pkt); |
1960 } | 1964 } |
1961 } else { | 1965 } else |
| 1966 #endif |
| 1967 { |
1962 MatroskaTrackEncoding *encodings = track->encodings.elem; | 1968 MatroskaTrackEncoding *encodings = track->encodings.elem; |
1963 int offset = 0, pkt_size = lace_size[n]; | 1969 int offset = 0, pkt_size = lace_size[n]; |
1964 uint8_t *pkt_data = data; | 1970 uint8_t *pkt_data = data; |
1965 | 1971 |
1966 if (pkt_size > size) { | 1972 if (pkt_size > size) { |
1967 av_log(matroska->ctx, AV_LOG_ERROR, "Invalid packet size\n")
; | 1973 av_log(matroska->ctx, AV_LOG_ERROR, "Invalid packet size\n")
; |
1968 break; | 1974 break; |
1969 } | 1975 } |
1970 | 1976 |
1971 if (encodings && encodings->scope & 1) { | 1977 if (encodings && encodings->scope & 1) { |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 AVInputFormat ff_matroska_demuxer = { | 2205 AVInputFormat ff_matroska_demuxer = { |
2200 .name = "matroska,webm", | 2206 .name = "matroska,webm", |
2201 .long_name = NULL_IF_CONFIG_SMALL("Matroska/WebM file format"), | 2207 .long_name = NULL_IF_CONFIG_SMALL("Matroska/WebM file format"), |
2202 .priv_data_size = sizeof(MatroskaDemuxContext), | 2208 .priv_data_size = sizeof(MatroskaDemuxContext), |
2203 .read_probe = matroska_probe, | 2209 .read_probe = matroska_probe, |
2204 .read_header = matroska_read_header, | 2210 .read_header = matroska_read_header, |
2205 .read_packet = matroska_read_packet, | 2211 .read_packet = matroska_read_packet, |
2206 .read_close = matroska_read_close, | 2212 .read_close = matroska_read_close, |
2207 .read_seek = matroska_read_seek, | 2213 .read_seek = matroska_read_seek, |
2208 }; | 2214 }; |
OLD | NEW |