AVCodecEncoder should not know the format

This commit is contained in:
Dario Casalinuovo 2015-12-04 01:14:15 +01:00
parent 537ea80adf
commit c3b461d8a9
3 changed files with 9 additions and 22 deletions

View File

@ -54,25 +54,6 @@ AVCodecEncoder::AVCodecEncoder(uint32 codecID, int bitRateScale)
}
AVCodecEncoder::AVCodecEncoder(const media_format& format)
:
Encoder(),
fBitRateScale(1), // TODO: is it OK?
fCodecID(CodecID(-1)),
fCodec(NULL),
fOwnContext(avcodec_alloc_context3(NULL)),
fContext(fOwnContext),
fCodecInitStatus(CODEC_INIT_NEEDED),
fFrame(avcodec_alloc_frame()),
fSwsContext(NULL),
fFramesWritten(0)
{
TRACE("AVCodecEncoder::AVCodecEncoder()\n");
_Init();
SetUp(&format);
}
void
AVCodecEncoder::_Init()
{

View File

@ -27,8 +27,6 @@ public:
AVCodecEncoder(uint32 codecID,
int bitRateScale);
AVCodecEncoder(const media_format& format);
virtual ~AVCodecEncoder();
virtual status_t AcceptedFormat(

View File

@ -159,7 +159,15 @@ FFmpegPlugin::NewEncoder(const media_codec_info& codecInfo)
Encoder*
FFmpegPlugin::NewEncoder(const media_format& format)
{
return new(std::nothrow)AVCodecEncoder(format);
for (size_t i = 0; i < gEncoderCount; i++) {
media_format destFormat;
if (format.type == gEncoderTable[i].output_type) {
return new(std::nothrow)AVCodecEncoder(
gEncoderTable[i].codec_info.sub_id,
gEncoderTable[i].bit_rate_scale);
}
}
return NULL;
}