History

ogg/flac: implement header packet skip in chained ogg bitstreams.

Romain Beauxis committed 1 year ago

Commit 2fb64161 parent bd2dcfa2 files · +26 −4Browse files

Unified · Split

2 files
  1. libavformat/oggparseflac.c +26 −2
  2. tests/ref/fate/ogg-flac-chained-meta.txt +0 −2
libavformat/oggparseflac.c+26−2
@@ -27,6 +27,8 @@ · 26 unmodified lines
27#include "oggdec.h"27#include "oggdec.h"
28 28
29#define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F29#define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F
30#define OGG_FLAC_MAGIC "\177FLAC"
31#define OGG_FLAC_MAGIC_SIZE sizeof(OGG_FLAC_MAGIC)-1
30 32
31static int33static int
32flac_header (AVFormatContext * s, int idx)34flac_header (AVFormatContext * s, int idx)
@@ -78,6 +80,27 @@ flac_header (AVFormatContext * s, int idx) · 45 unmodified lines
78 return 1;80 return 1;
79}81}
80 82
83static int
84flac_packet (AVFormatContext * s, int idx)
85{
86 struct ogg *ogg = s->priv_data;
87 struct ogg_stream *os = ogg->streams + idx;
88
89 if (os->psize > OGG_FLAC_MAGIC_SIZE &&
90 !memcmp(
91 os->buf + os->pstart,
92 OGG_FLAC_MAGIC,
93 OGG_FLAC_MAGIC_SIZE))
94 return 1;
95
96 if (os->psize > 0 &&
97 ((os->buf[os->pstart] & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT)) {
98 return 1;
99 }
100
101 return 0;
102}
103
81static int104static int
82old_flac_header (AVFormatContext * s, int idx)105old_flac_header (AVFormatContext * s, int idx)
83{106{
@@ -127,10 +150,11 @@ fail: · 43 unmodified lines
127}150}
128 151
129const struct ogg_codec ff_flac_codec = {152const struct ogg_codec ff_flac_codec = {
130 .magic = "\177FLAC",153 .magic = OGG_FLAC_MAGIC,
131 .magicsize = 5,154 .magicsize = OGG_FLAC_MAGIC_SIZE,
132 .header = flac_header,155 .header = flac_header,
133 .nb_header = 2,156 .nb_header = 2,
157 .packet = flac_packet,
134};158};
135 159
136const struct ogg_codec ff_old_flac_codec = {160const struct ogg_codec ff_old_flac_codec = {
tests/ref/fate/ogg-flac-chained-meta.txt+0−2
@@ -5,8 +5,6 @@ Stream ID: 0, frame PTS: 0, metadata: N/A · 4 unmodified lines
5Stream ID: 0, packet PTS: 4608, packet DTS: 46085Stream ID: 0, packet PTS: 4608, packet DTS: 4608
6Stream ID: 0, frame PTS: 4608, metadata: N/A6Stream ID: 0, frame PTS: 4608, metadata: N/A
7Stream ID: 0, packet PTS: 0, packet DTS: 07Stream ID: 0, packet PTS: 0, packet DTS: 0
8Stream ID: 0, packet PTS: 0, packet DTS: 0
9Stream ID: 0, packet PTS: 0, packet DTS: 0
10Stream ID: 0, frame PTS: 0, metadata: N/A8Stream ID: 0, frame PTS: 0, metadata: N/A
11Stream ID: 0, packet PTS: 4608, packet DTS: 46089Stream ID: 0, packet PTS: 4608, packet DTS: 4608
12Stream ID: 0, frame PTS: 4608, metadata: N/A10Stream ID: 0, frame PTS: 4608, metadata: N/A

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