summaryrefslogtreecommitdiff
path: root/ffmpeg/libavcodec/wmaenc.c
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/wmaenc.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/wmaenc.c')
-rw-r--r--ffmpeg/libavcodec/wmaenc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ffmpeg/libavcodec/wmaenc.c b/ffmpeg/libavcodec/wmaenc.c
index 799535e..895a180 100644
--- a/ffmpeg/libavcodec/wmaenc.c
+++ b/ffmpeg/libavcodec/wmaenc.c
@@ -19,13 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/attributes.h"
#include "avcodec.h"
#include "internal.h"
#include "wma.h"
#include "libavutil/avassert.h"
-static int encode_init(AVCodecContext * avctx){
+static av_cold int encode_init(AVCodecContext *avctx)
+{
WMACodecContext *s = avctx->priv_data;
int i, flags1, flags2, block_align;
uint8_t *extradata;
@@ -175,7 +177,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
}
s->block_len = 1 << s->block_len_bits;
-// assert((s->block_pos + s->block_len) <= s->frame_len);
+// av_assert0((s->block_pos + s->block_len) <= s->frame_len);
bsize = s->frame_len_bits - s->block_len_bits;
//FIXME factor
@@ -374,6 +376,11 @@ static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt,
while(total_gain <= 128 && error > 0)
error = encode_frame(s, s->coefs, avpkt->data, avpkt->size, total_gain++);
+ if (error > 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid input data or requested bitrate too low, cannot encode\n");
+ avpkt->size = 0;
+ return AVERROR(EINVAL);
+ }
av_assert0((put_bits_count(&s->pb) & 7) == 0);
i= avctx->block_align - (put_bits_count(&s->pb)+7)/8;
av_assert0(i>=0);
@@ -394,6 +401,7 @@ static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt,
#if CONFIG_WMAV1_ENCODER
AVCodec ff_wmav1_encoder = {
.name = "wmav1",
+ .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_WMAV1,
.priv_data_size = sizeof(WMACodecContext),
@@ -402,12 +410,12 @@ AVCodec ff_wmav1_encoder = {
.close = ff_wma_end,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
};
#endif
#if CONFIG_WMAV2_ENCODER
AVCodec ff_wmav2_encoder = {
.name = "wmav2",
+ .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_WMAV2,
.priv_data_size = sizeof(WMACodecContext),
@@ -416,6 +424,5 @@ AVCodec ff_wmav2_encoder = {
.close = ff_wma_end,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
};
#endif