History

avformat: add binka demuxer

Paul B Mahol committed 5 years ago

Commit e955f5a1 parent b12e7135 files · +105 −2Browse files

Unified · Split

5 files
  1. Changelog +1 −0
  2. libavformat/Makefile +1 −0
  3. libavformat/allformats.c +1 −0
  4. libavformat/binka.c +100 −0
  5. libavformat/version.h +2 −2
Changelog+1−0
@@ -64,6 +64,7 @@ version <next>: · 63 unmodified lines
64- colorcontrast filter64- colorcontrast filter
65- PFM encoder65- PFM encoder
66- colorcorrect filter66- colorcorrect filter
67- binka demuxer
67 68
68 69
69version 4.3:70version 4.3:
libavformat/Makefile+1−0
@@ -129,6 +129,7 @@ OBJS-$(CONFIG_AVS3_DEMUXER) += avs3dec.o rawdec.o · 128 unmodified lines
129OBJS-$(CONFIG_BETHSOFTVID_DEMUXER) += bethsoftvid.o129OBJS-$(CONFIG_BETHSOFTVID_DEMUXER) += bethsoftvid.o
130OBJS-$(CONFIG_BFI_DEMUXER) += bfi.o130OBJS-$(CONFIG_BFI_DEMUXER) += bfi.o
131OBJS-$(CONFIG_BINK_DEMUXER) += bink.o131OBJS-$(CONFIG_BINK_DEMUXER) += bink.o
132OBJS-$(CONFIG_BINKA_DEMUXER) += binka.o
132OBJS-$(CONFIG_BINTEXT_DEMUXER) += bintext.o sauce.o133OBJS-$(CONFIG_BINTEXT_DEMUXER) += bintext.o sauce.o
133OBJS-$(CONFIG_BIT_DEMUXER) += bit.o134OBJS-$(CONFIG_BIT_DEMUXER) += bit.o
134OBJS-$(CONFIG_BIT_MUXER) += bit.o135OBJS-$(CONFIG_BIT_MUXER) += bit.o
libavformat/allformats.c+1−0
@@ -94,6 +94,7 @@ extern AVInputFormat ff_bethsoftvid_demuxer; · 93 unmodified lines
94extern AVInputFormat ff_bfi_demuxer;94extern AVInputFormat ff_bfi_demuxer;
95extern AVInputFormat ff_bintext_demuxer;95extern AVInputFormat ff_bintext_demuxer;
96extern AVInputFormat ff_bink_demuxer;96extern AVInputFormat ff_bink_demuxer;
97extern AVInputFormat ff_binka_demuxer;
97extern AVInputFormat ff_bit_demuxer;98extern AVInputFormat ff_bit_demuxer;
98extern AVOutputFormat ff_bit_muxer;99extern AVOutputFormat ff_bit_muxer;
99extern AVInputFormat ff_bmv_demuxer;100extern AVInputFormat ff_bmv_demuxer;
libavformat/binka.c+100−0
@@ -0,0 +1,100 @@
1/*
2 * Copyright (c) 2021 Paul B Mahol
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "libavutil/intreadwrite.h"
22#include "avformat.h"
23#include "internal.h"
24
25static int binka_probe(const AVProbeData *p)
26{
27 if (AV_RB32(p->buf) == MKBETAG('1', 'F', 'C', 'B') &&
28 (p->buf[4] == 1 || p->buf[4] == 2))
29 return AVPROBE_SCORE_MAX;
30 return 0;
31}
32
33static int binka_read_header(AVFormatContext *s)
34{
35 AVIOContext *pb = s->pb;
36 AVStream *st;
37 int entries, offset;
38
39 st = avformat_new_stream(s, NULL);
40 if (!st)
41 return AVERROR(ENOMEM);
42
43 avio_skip(pb, 5);
44
45 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
46 st->codecpar->codec_id = AV_CODEC_ID_BINKAUDIO_DCT;
47 st->codecpar->channels = avio_r8(pb);
48 st->codecpar->sample_rate = avio_rl16(pb);
49 st->duration = avio_rl32(pb);
50
51 avio_skip(pb, 8);
52 entries = avio_rl16(pb);
53
54 offset = entries * 2 + 2;
55 avio_skip(pb, offset);
56
57 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
58
59 return 0;
60}
61
62static int binka_read_packet(AVFormatContext *s, AVPacket *pkt)
63{
64 AVIOContext *pb = s->pb;
65 AVStream *st = s->streams[0];
66 int64_t pos;
67 int pkt_size;
68 int ret;
69
70 if (avio_feof(pb))
71 return AVERROR_EOF;
72
73 pos = avio_tell(pb);
74 avio_skip(pb, 2);
75 pkt_size = avio_rl16(pb) + 4;
76 if (pkt_size <= 4)
77 return AVERROR(EIO);
78 ret = av_new_packet(pkt, pkt_size);
79 if (ret < 0)
80 return ret;
81
82 avio_read(pb, pkt->data + 4, pkt_size - 4);
83 AV_WL32(pkt->data, pkt_size);
84
85 pkt->pos = pos;
86 pkt->stream_index = 0;
87 pkt->duration = av_get_audio_frame_duration2(st->codecpar, 0);
88
89 return 0;
90}
91
92AVInputFormat ff_binka_demuxer = {
93 .name = "binka",
94 .long_name = NULL_IF_CONFIG_SMALL("Bink Audio"),
95 .read_probe = binka_probe,
96 .read_header = binka_read_header,
97 .read_packet = binka_read_packet,
98 .flags = AVFMT_GENERIC_INDEX,
99 .extensions = "binka",
100};
libavformat/version.h+2−2
@@ -32,8 +32,8 @@ · 31 unmodified lines
32// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)32// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
33// Also please add any ticket numbers that you believe might be affected here33// Also please add any ticket numbers that you believe might be affected here
34#define LIBAVFORMAT_VERSION_MAJOR 5834#define LIBAVFORMAT_VERSION_MAJOR 58
35#define LIBAVFORMAT_VERSION_MINOR 6535#define LIBAVFORMAT_VERSION_MINOR 66
36#define LIBAVFORMAT_VERSION_MICRO 10136#define LIBAVFORMAT_VERSION_MICRO 100
37 37
38#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \38#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
39 LIBAVFORMAT_VERSION_MINOR, \39 LIBAVFORMAT_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t