mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-27 07:22:44 +02:00
libeplayer3/writer: implement decoder flushing
Origin commit data
------------------
Branch: master
Commit: 87167a7f5d
Author: martii <m4rtii@gmx.de>
Date: 2014-04-27 (Sun, 27 Apr 2014)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -9,7 +9,7 @@ libeplayer3_la_SOURCES = \
|
|||||||
input.cpp output.cpp manager.cpp player.cpp \
|
input.cpp output.cpp manager.cpp player.cpp \
|
||||||
writer/writer.cpp writer/wmv.cpp writer/ac3.cpp writer/divx.cpp writer/pes.cpp \
|
writer/writer.cpp writer/wmv.cpp writer/ac3.cpp writer/divx.cpp writer/pes.cpp \
|
||||||
writer/dts.cpp writer/mpeg2.cpp writer/mp3.cpp writer/misc.cpp writer/h264.cpp \
|
writer/dts.cpp writer/mpeg2.cpp writer/mp3.cpp writer/misc.cpp writer/h264.cpp \
|
||||||
writer/h263.cpp writer/vc1.cpp writer/flac.cpp writer/pcm.cpp
|
writer/h263.cpp writer/vc1.cpp writer/pcm.cpp
|
||||||
|
|
||||||
LIBEPLAYER3_LIBS = libeplayer3.la -lpthread -lavformat -lavcodec -lavutil -lswresample -lm
|
LIBEPLAYER3_LIBS = libeplayer3.la -lpthread -lavformat -lavcodec -lavutil -lswresample -lm
|
||||||
|
|
||||||
|
@@ -230,7 +230,8 @@ bool Input::Play()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_teletextTrack && (_teletextTrack->stream == stream)) {
|
} else if (_teletextTrack && (_teletextTrack->stream == stream)) {
|
||||||
teletext_write(stream->id, packet.data, packet.size);
|
if (packet.data && packet.size > 1)
|
||||||
|
teletext_write(stream->id, packet.data + 1, packet.size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_free_packet(&packet);
|
av_free_packet(&packet);
|
||||||
@@ -238,8 +239,17 @@ bool Input::Play()
|
|||||||
|
|
||||||
if (player->abortRequested)
|
if (player->abortRequested)
|
||||||
player->output.Clear();
|
player->output.Clear();
|
||||||
else
|
else {
|
||||||
|
Track *_audioTrack = audioTrack;
|
||||||
|
if (_audioTrack) {
|
||||||
|
// flush audio decoder
|
||||||
|
AVPacket packet;
|
||||||
|
av_init_packet(&packet);
|
||||||
|
packet.size = 0;
|
||||||
|
player->output.Write(avfc, _audioTrack->stream, &packet, 0);
|
||||||
|
}
|
||||||
player->output.Flush();
|
player->output.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
dvbsub_ass_clear();
|
dvbsub_ass_clear();
|
||||||
abortPlayback = true;
|
abortPlayback = true;
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "pes.h"
|
#include "pes.h"
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
@@ -39,18 +41,26 @@ class WriterAC3 : public Writer
|
|||||||
|
|
||||||
bool WriterAC3::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
bool WriterAC3::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||||
|
|
||||||
|
for (int pos = 0; pos < packet->size; ) {
|
||||||
|
int PacketLength = std::min(packet->size - pos, MAX_PES_PACKET_SIZE);
|
||||||
struct iovec iov[2];
|
struct iovec iov[2];
|
||||||
|
|
||||||
iov[0].iov_base = PesHeader;
|
iov[0].iov_base = PesHeader;
|
||||||
iov[0].iov_len = InsertPesHeader(PesHeader, packet->size, PRIVATE_STREAM_1_PES_START_CODE, pts, 0);
|
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, PRIVATE_STREAM_1_PES_START_CODE, pts, 0);
|
||||||
iov[1].iov_base = packet->data;
|
iov[1].iov_base = packet->data + pos;
|
||||||
iov[1].iov_len = packet->size;
|
iov[1].iov_len = PacketLength;
|
||||||
|
|
||||||
return writev(fd, iov, 2) > -1;
|
ssize_t l = writev(fd, iov, 2);
|
||||||
|
if (l < 0)
|
||||||
|
return false;
|
||||||
|
pos += PacketLength;
|
||||||
|
pts = INVALID_PTS_VALUE;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriterAC3::WriterAC3()
|
WriterAC3::WriterAC3()
|
||||||
|
@@ -50,7 +50,7 @@ void WriterDIVX::Init()
|
|||||||
|
|
||||||
bool WriterDIVX::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AVPacket *packet, int64_t pts)
|
bool WriterDIVX::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||||
|
@@ -42,7 +42,7 @@ class WriterDTS : public Writer
|
|||||||
|
|
||||||
bool WriterDTS::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
bool WriterDTS::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t PesHeader[PES_AUDIO_HEADER_SIZE];
|
uint8_t PesHeader[PES_AUDIO_HEADER_SIZE];
|
||||||
|
@@ -26,8 +26,10 @@
|
|||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "pes.h"
|
#include <algorithm>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "pes.h"
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
|
|
||||||
class WriterFLAC : public Writer
|
class WriterFLAC : public Writer
|
||||||
@@ -39,18 +41,26 @@ class WriterFLAC : public Writer
|
|||||||
|
|
||||||
bool WriterFLAC::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
bool WriterFLAC::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||||
|
|
||||||
|
for (int pos = 0; pos < packet->size; ) {
|
||||||
|
int PacketLength = std::min(packet->size - pos, MAX_PES_PACKET_SIZE);
|
||||||
struct iovec iov[2];
|
struct iovec iov[2];
|
||||||
|
|
||||||
iov[0].iov_base = PesHeader;
|
iov[0].iov_base = PesHeader;
|
||||||
iov[0].iov_len = InsertPesHeader(PesHeader, packet->size, MPEG_AUDIO_PES_START_CODE, pts, 0);
|
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, MPEG_AUDIO_PES_START_CODE, pts, 0);
|
||||||
iov[1].iov_base = packet->data;
|
iov[1].iov_base = packet->data + pos;
|
||||||
iov[1].iov_len = packet->size;
|
iov[1].iov_len = PacketLength;
|
||||||
|
|
||||||
return writev(fd, iov, 2) > -1;
|
ssize_t l = writev(fd, iov, 2);
|
||||||
|
if (l < 0)
|
||||||
|
return false;
|
||||||
|
pos += PacketLength;
|
||||||
|
pts = INVALID_PTS_VALUE;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriterFLAC::WriterFLAC()
|
WriterFLAC::WriterFLAC()
|
||||||
|
@@ -38,7 +38,7 @@ class WriterH263 : public Writer
|
|||||||
|
|
||||||
bool WriterH263::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
bool WriterH263::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ void WriterH264::Init(void)
|
|||||||
|
|
||||||
bool WriterH264::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AVPacket *packet, int64_t pts)
|
bool WriterH264::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||||
unsigned int TimeDelta;
|
unsigned int TimeDelta;
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "pes.h"
|
#include "pes.h"
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
@@ -39,18 +41,26 @@ class WriterMP3 : public Writer
|
|||||||
|
|
||||||
bool WriterMP3::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
bool WriterMP3::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||||
|
|
||||||
|
for (int pos = 0; pos < packet->size; ) {
|
||||||
|
int PacketLength = std::min(packet->size - pos, MAX_PES_PACKET_SIZE);
|
||||||
struct iovec iov[2];
|
struct iovec iov[2];
|
||||||
|
|
||||||
iov[0].iov_base = PesHeader;
|
iov[0].iov_base = PesHeader;
|
||||||
iov[0].iov_len = InsertPesHeader(PesHeader, packet->size, MPEG_AUDIO_PES_START_CODE, pts, 0);
|
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, MPEG_AUDIO_PES_START_CODE, pts, 0);
|
||||||
iov[1].iov_base = packet->data;
|
iov[1].iov_base = packet->data + pos;
|
||||||
iov[1].iov_len = packet->size;
|
iov[1].iov_len = PacketLength;
|
||||||
|
|
||||||
return writev(fd, iov, 2) > -1;
|
ssize_t l = writev(fd, iov, 2);
|
||||||
|
if (l < 0)
|
||||||
|
return false;
|
||||||
|
pos += PacketLength;
|
||||||
|
pts = INVALID_PTS_VALUE;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriterMP3::WriterMP3()
|
WriterMP3::WriterMP3()
|
||||||
@@ -58,6 +68,7 @@ WriterMP3::WriterMP3()
|
|||||||
Register(this, AV_CODEC_ID_MP3, AUDIO_ENCODING_MP3);
|
Register(this, AV_CODEC_ID_MP3, AUDIO_ENCODING_MP3);
|
||||||
Register(this, AV_CODEC_ID_MP2, AUDIO_ENCODING_MPEG2);
|
Register(this, AV_CODEC_ID_MP2, AUDIO_ENCODING_MPEG2);
|
||||||
// Register(this, AV_CODEC_ID_VORBIS, AUDIO_ENCODING_VORBIS);
|
// Register(this, AV_CODEC_ID_VORBIS, AUDIO_ENCODING_VORBIS);
|
||||||
|
Register(this, AV_CODEC_ID_FLAC, AUDIO_ENCODING_LPCM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WriterMP3 writer_mp3 __attribute__ ((init_priority (300)));
|
static WriterMP3 writer_mp3 __attribute__ ((init_priority (300)));
|
||||||
|
@@ -41,25 +41,23 @@ class WriterMPEG2 : public Writer
|
|||||||
|
|
||||||
bool WriterMPEG2::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
bool WriterMPEG2::Write(int fd, AVFormatContext * /* avfc */, AVStream * /* stream */, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
uint8_t PesHeader[PES_MAX_HEADER_SIZE];
|
||||||
|
|
||||||
for (int Position = 0; Position < packet->size; ) {
|
for (int pos = 0; pos < packet->size; ) {
|
||||||
int PacketLength = std::min(packet->size - Position, MAX_PES_PACKET_SIZE);
|
int PacketLength = std::min(packet->size - pos, MAX_PES_PACKET_SIZE);
|
||||||
struct iovec iov[2];
|
struct iovec iov[2];
|
||||||
iov[0].iov_base = PesHeader;
|
iov[0].iov_base = PesHeader;
|
||||||
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, 0xe0, pts, 0);
|
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, MPEG_VIDEO_PES_START_CODE, pts, 0);
|
||||||
iov[1].iov_base = packet->data + Position;
|
iov[1].iov_base = packet->data + pos;
|
||||||
iov[1].iov_len = PacketLength;
|
iov[1].iov_len = PacketLength;
|
||||||
|
|
||||||
ssize_t l = writev(fd, iov, 2);
|
ssize_t l = writev(fd, iov, 2);
|
||||||
if (l < 0) {
|
if (l < 0)
|
||||||
return false;
|
return false;
|
||||||
break;
|
pos += PacketLength;
|
||||||
}
|
|
||||||
Position += PacketLength;
|
|
||||||
pts = INVALID_PTS_VALUE;
|
pts = INVALID_PTS_VALUE;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -64,6 +64,8 @@ class WriterPCM : public Writer
|
|||||||
uint8_t lpcm_prv[14];
|
uint8_t lpcm_prv[14];
|
||||||
uint8_t injectBuffer[2048];
|
uint8_t injectBuffer[2048];
|
||||||
uint8_t breakBuffer[sizeof(injectBuffer)];
|
uint8_t breakBuffer[sizeof(injectBuffer)];
|
||||||
|
uint8_t *output;
|
||||||
|
uint8_t out_samples_max;
|
||||||
unsigned int breakBufferFillSize;
|
unsigned int breakBufferFillSize;
|
||||||
int uNoOfChannels;
|
int uNoOfChannels;
|
||||||
int uSampleRate;
|
int uSampleRate;
|
||||||
@@ -209,7 +211,7 @@ bool WriterPCM::writePCM(int fd, int64_t Pts, uint8_t *data, unsigned int size)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (size) {
|
if (size && res) {
|
||||||
breakBufferFillSize = size;
|
breakBufferFillSize = size;
|
||||||
memcpy(breakBuffer, data, size);
|
memcpy(breakBuffer, data, size);
|
||||||
}
|
}
|
||||||
@@ -234,20 +236,19 @@ bool WriterPCM::Write(int fd, AVFormatContext * /*avfc*/, AVStream *stream, AVPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
AVCodecContext *c = stream->codec;
|
AVCodecContext *c = stream->codec;
|
||||||
unsigned int packet_size = packet->size;
|
|
||||||
|
|
||||||
if (restart_audio_resampling) {
|
if (restart_audio_resampling) {
|
||||||
restart_audio_resampling = false;
|
restart_audio_resampling = false;
|
||||||
initialHeader = true;
|
initialHeader = true;
|
||||||
|
|
||||||
if (swr)
|
|
||||||
swr_free(&swr);
|
swr_free(&swr);
|
||||||
if (decoded_frame)
|
|
||||||
av_frame_free(&decoded_frame);
|
|
||||||
|
|
||||||
AVCodec *codec = avcodec_find_decoder(c->codec_id);
|
AVCodec *codec = avcodec_find_decoder(c->codec_id);
|
||||||
|
if (!codec) {
|
||||||
if (!codec || avcodec_open2(c, codec, NULL)) {
|
fprintf(stderr, "%s %d: avcodec_find_decoder(%llx)\n", __func__, __LINE__, (unsigned long long) c->codec_id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (avcodec_open2(c, codec, NULL)) {
|
||||||
fprintf(stderr, "%s %d: avcodec_open2 failed\n", __func__, __LINE__);
|
fprintf(stderr, "%s %d: avcodec_open2 failed\n", __func__, __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -294,59 +295,62 @@ bool WriterPCM::Write(int fd, AVFormatContext * /*avfc*/, AVStream *stream, AVPa
|
|||||||
fprintf(stderr, "swr_init: %d (icl=%d ocl=%d isr=%d osr=%d isf=%d osf=%d\n",
|
fprintf(stderr, "swr_init: %d (icl=%d ocl=%d isr=%d osr=%d isf=%d osf=%d\n",
|
||||||
-e, (int) c->channel_layout,
|
-e, (int) c->channel_layout,
|
||||||
(int) out_channel_layout, c->sample_rate, out_sample_rate, c->sample_fmt, AV_SAMPLE_FMT_S16);
|
(int) out_channel_layout, c->sample_rate, out_sample_rate, c->sample_fmt, AV_SAMPLE_FMT_S16);
|
||||||
swr_free(&swr);
|
|
||||||
restart_audio_resampling = true;
|
restart_audio_resampling = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (packet_size > 0) {
|
unsigned int packet_size = packet->size;
|
||||||
int got_frame = 0;
|
while (packet_size > 0 || (!packet_size && !packet->data)) {
|
||||||
if (decoded_frame)
|
|
||||||
av_frame_unref(decoded_frame);
|
av_frame_unref(decoded_frame);
|
||||||
else if (!(decoded_frame = av_frame_alloc())) {
|
|
||||||
fprintf(stderr, "out of memory\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
int got_frame = 0;
|
||||||
int len = avcodec_decode_audio4(c, decoded_frame, &got_frame, packet);
|
int len = avcodec_decode_audio4(c, decoded_frame, &got_frame, packet);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
restart_audio_resampling = true;
|
restart_audio_resampling = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet_size -= len;
|
if (!got_frame) {
|
||||||
|
if (!packet->data)
|
||||||
if (!got_frame)
|
break;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int in_samples = decoded_frame->nb_samples;
|
int in_samples = decoded_frame->nb_samples;
|
||||||
int out_samples = av_rescale_rnd(swr_get_delay(swr, c->sample_rate) + in_samples, out_sample_rate, c->sample_rate, AV_ROUND_UP);
|
int out_samples = av_rescale_rnd(swr_get_delay(swr, c->sample_rate) + in_samples, out_sample_rate, c->sample_rate, AV_ROUND_UP);
|
||||||
|
if (out_samples > out_samples_max) {
|
||||||
uint8_t *output = NULL;
|
if (output)
|
||||||
|
av_freep(&output);
|
||||||
int e = av_samples_alloc(&output, NULL, out_channels, out_samples, AV_SAMPLE_FMT_S16, 1);
|
int e = av_samples_alloc(&output, NULL, out_channels, out_samples, AV_SAMPLE_FMT_S16, 1);
|
||||||
if (e < 0) {
|
if (e < 0) {
|
||||||
fprintf(stderr, "av_samples_alloc: %d\n", -e);
|
fprintf(stderr, "av_samples_alloc: %d\n", -e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
out_samples_max = out_samples;
|
||||||
|
}
|
||||||
|
|
||||||
out_samples = swr_convert(swr, &output, out_samples, (const uint8_t **) &decoded_frame->data[0], in_samples);
|
out_samples = swr_convert(swr, &output, out_samples, (const uint8_t **) &decoded_frame->data[0], in_samples);
|
||||||
|
|
||||||
if (!writePCM(fd, pts, output, out_samples * sizeof(short) * out_channels)) {
|
if (!writePCM(fd, pts, output, out_samples * sizeof(short) * out_channels)) {
|
||||||
restart_audio_resampling = true;
|
restart_audio_resampling = true;
|
||||||
av_free(output);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_free(output);
|
|
||||||
pts = 0;
|
pts = 0;
|
||||||
|
|
||||||
|
if (packet->data)
|
||||||
|
packet_size -= len;
|
||||||
}
|
}
|
||||||
return true;
|
return !packet_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriterPCM::WriterPCM()
|
WriterPCM::WriterPCM()
|
||||||
{
|
{
|
||||||
swr = NULL;
|
swr = NULL;
|
||||||
decoded_frame = NULL;
|
output = NULL;
|
||||||
|
out_samples_max = 0;
|
||||||
|
decoded_frame = av_frame_alloc();
|
||||||
|
|
||||||
Register(this, AV_CODEC_ID_INJECTPCM, AUDIO_ENCODING_LPCMA);
|
Register(this, AV_CODEC_ID_INJECTPCM, AUDIO_ENCODING_LPCMA);
|
||||||
Init();
|
Init();
|
||||||
|
@@ -63,7 +63,7 @@ void WriterVC1::Init()
|
|||||||
|
|
||||||
bool WriterVC1::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AVPacket *packet, int64_t pts)
|
bool WriterVC1::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (initialHeader) {
|
if (initialHeader) {
|
||||||
|
@@ -70,7 +70,7 @@ void WriterWMV::Init()
|
|||||||
|
|
||||||
bool WriterWMV::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AVPacket *packet, int64_t pts)
|
bool WriterWMV::Write(int fd, AVFormatContext * /* avfc */, AVStream *stream, AVPacket *packet, int64_t pts)
|
||||||
{
|
{
|
||||||
if (fd < 0 || !packet)
|
if (fd < 0 || !packet || !packet->data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (initialHeader) {
|
if (initialHeader) {
|
||||||
|
Reference in New Issue
Block a user