summaryrefslogtreecommitdiff
path: root/ffmpeg/libavcodec/libschroedingerenc.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/libschroedingerenc.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/libschroedingerenc.c')
-rw-r--r--ffmpeg/libavcodec/libschroedingerenc.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/ffmpeg/libavcodec/libschroedingerenc.c b/ffmpeg/libavcodec/libschroedingerenc.c
index 297c6c5..294fb06 100644
--- a/ffmpeg/libavcodec/libschroedingerenc.c
+++ b/ffmpeg/libavcodec/libschroedingerenc.c
@@ -31,6 +31,7 @@
#include <schroedinger/schrodebug.h>
#include <schroedinger/schrovideoformat.h>
+#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "avcodec.h"
#include "internal.h"
@@ -46,9 +47,6 @@ typedef struct SchroEncoderParams {
/** Schroedinger frame format */
SchroFrameFormat frame_format;
- /** frame being encoded */
- AVFrame picture;
-
/** frame size */
int frame_size;
@@ -100,7 +98,7 @@ static int set_chroma_format(AVCodecContext *avctx)
return -1;
}
-static int libschroedinger_encode_init(AVCodecContext *avctx)
+static av_cold int libschroedinger_encode_init(AVCodecContext *avctx)
{
SchroEncoderParams *p_schro_params = avctx->priv_data;
SchroVideoFormatEnum preset;
@@ -161,7 +159,9 @@ static int libschroedinger_encode_init(AVCodecContext *avctx)
avctx->width,
avctx->height);
- avctx->coded_frame = &p_schro_params->picture;
+ avctx->coded_frame = av_frame_alloc();
+ if (!avctx->coded_frame)
+ return AVERROR(ENOMEM);
if (!avctx->gop_size) {
schro_encoder_setting_set_double(p_schro_params->encoder,
@@ -293,21 +293,27 @@ static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
/* Now check to see if we have any output from the encoder. */
while (go) {
+ int err;
SchroStateEnum state;
state = schro_encoder_wait(encoder);
switch (state) {
case SCHRO_STATE_HAVE_BUFFER:
case SCHRO_STATE_END_OF_STREAM:
enc_buf = schro_encoder_pull(encoder, &presentation_frame);
- av_assert0(enc_buf->length > 0);
+ if (enc_buf->length <= 0)
+ return AVERROR_BUG;
parse_code = enc_buf->data[4];
/* All non-frame data is prepended to actual frame data to
* be able to set the pts correctly. So we don't write data
* to the frame output queue until we actually have a frame
*/
- p_schro_params->enc_buf = av_realloc(p_schro_params->enc_buf,
- p_schro_params->enc_buf_size + enc_buf->length);
+ if ((err = av_reallocp(&p_schro_params->enc_buf,
+ p_schro_params->enc_buf_size +
+ enc_buf->length)) < 0) {
+ p_schro_params->enc_buf_size = 0;
+ return err;
+ }
memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size,
enc_buf->data, enc_buf->length);
@@ -426,12 +432,15 @@ static int libschroedinger_encode_close(AVCodecContext *avctx)
/* Free the video format structure. */
av_freep(&p_schro_params->format);
+ av_frame_free(&avctx->coded_frame);
+
return 0;
}
AVCodec ff_libschroedinger_encoder = {
.name = "libschroedinger",
+ .long_name = NULL_IF_CONFIG_SMALL("libschroedinger Dirac 2.2"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_DIRAC,
.priv_data_size = sizeof(SchroEncoderParams),
@@ -442,5 +451,4 @@ AVCodec ff_libschroedinger_encoder = {
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE
},
- .long_name = NULL_IF_CONFIG_SMALL("libschroedinger Dirac 2.2"),
};