Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
068de7cf
Commit
068de7cf
authored
May 09, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encoder/ogg: use class OggStreamState
parent
d04eb87c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
14 deletions
+32
-14
OggEncoder.hxx
src/encoder/plugins/OggEncoder.hxx
+28
-10
OpusEncoderPlugin.cxx
src/encoder/plugins/OpusEncoderPlugin.cxx
+3
-3
VorbisEncoderPlugin.cxx
src/encoder/plugins/VorbisEncoderPlugin.cxx
+1
-1
No files found.
src/encoder/plugins/OggEncoder.hxx
View file @
068de7cf
...
@@ -22,7 +22,8 @@
...
@@ -22,7 +22,8 @@
#include "config.h"
#include "config.h"
#include "../EncoderAPI.hxx"
#include "../EncoderAPI.hxx"
#include "lib/xiph/OggStream.hxx"
#include "lib/xiph/OggStreamState.hxx"
#include "lib/xiph/OggPage.hxx"
#include "lib/xiph/OggSerial.hxx"
#include "lib/xiph/OggSerial.hxx"
#include <ogg/ogg.h>
#include <ogg/ogg.h>
...
@@ -32,27 +33,44 @@
...
@@ -32,27 +33,44 @@
* with Ogg container output.
* with Ogg container output.
*/
*/
class
OggEncoder
:
public
Encoder
{
class
OggEncoder
:
public
Encoder
{
/* initialize "flush" to true, so the caller gets the full
headers on the first read */
bool
flush
=
true
;
protected
:
protected
:
OggStream
stream
;
OggStream
State
stream
;
public
:
public
:
OggEncoder
(
bool
_implements_tag
)
OggEncoder
(
bool
_implements_tag
)
:
Encoder
(
_implements_tag
)
{
:
Encoder
(
_implements_tag
),
stream
.
Initialize
(
GenerateOggSerial
());
stream
(
GenerateOggSerial
())
{
}
~
OggEncoder
()
override
{
stream
.
Deinitialize
();
}
}
/* virtual methods from class Encoder */
/* virtual methods from class Encoder */
bool
Flush
(
Error
&
)
override
{
bool
Flush
(
Error
&
)
override
{
stream
.
Flush
();
Flush
();
return
true
;
return
true
;
}
}
size_t
Read
(
void
*
dest
,
size_t
length
)
override
{
size_t
Read
(
void
*
dest
,
size_t
length
)
override
{
return
stream
.
PageOut
(
dest
,
length
);
ogg_page
page
;
bool
success
=
stream
.
PageOut
(
page
);
if
(
!
success
)
{
if
(
flush
)
{
flush
=
false
;
success
=
stream
.
Flush
(
page
);
}
if
(
!
success
)
return
0
;
}
return
ReadPage
(
page
,
dest
,
length
);
}
protected
:
void
Flush
()
{
flush
=
true
;
}
}
};
};
...
...
src/encoder/plugins/OpusEncoderPlugin.cxx
View file @
068de7cf
...
@@ -244,7 +244,7 @@ OpusEncoder::DoEncode(bool eos, Error &error)
...
@@ -244,7 +244,7 @@ OpusEncoder::DoEncode(bool eos, Error &error)
bool
bool
OpusEncoder
::
End
(
Error
&
error
)
OpusEncoder
::
End
(
Error
&
error
)
{
{
stream
.
Flush
();
Flush
();
memset
(
buffer
+
buffer_position
,
0
,
memset
(
buffer
+
buffer_position
,
0
,
buffer_size
-
buffer_position
);
buffer_size
-
buffer_position
);
...
@@ -331,7 +331,7 @@ OpusEncoder::GenerateHead()
...
@@ -331,7 +331,7 @@ OpusEncoder::GenerateHead()
packet
.
granulepos
=
0
;
packet
.
granulepos
=
0
;
packet
.
packetno
=
packetno
++
;
packet
.
packetno
=
packetno
++
;
stream
.
PacketIn
(
packet
);
stream
.
PacketIn
(
packet
);
stream
.
Flush
();
Flush
();
}
}
void
void
...
@@ -355,7 +355,7 @@ OpusEncoder::GenerateTags()
...
@@ -355,7 +355,7 @@ OpusEncoder::GenerateTags()
packet
.
granulepos
=
0
;
packet
.
granulepos
=
0
;
packet
.
packetno
=
packetno
++
;
packet
.
packetno
=
packetno
++
;
stream
.
PacketIn
(
packet
);
stream
.
PacketIn
(
packet
);
stream
.
Flush
();
Flush
();
free
(
comments
);
free
(
comments
);
}
}
...
...
src/encoder/plugins/VorbisEncoderPlugin.cxx
View file @
068de7cf
...
@@ -244,7 +244,7 @@ VorbisEncoder::PreTag(gcc_unused Error &error)
...
@@ -244,7 +244,7 @@ VorbisEncoder::PreTag(gcc_unused Error &error)
vorbis_analysis_init
(
&
vd
,
&
vi
);
vorbis_analysis_init
(
&
vd
,
&
vi
);
vorbis_block_init
(
&
vd
,
&
vb
);
vorbis_block_init
(
&
vd
,
&
vb
);
stream
.
Flush
();
Flush
();
return
true
;
return
true
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment