c->bit_rate = 64000;
c->sample_rate = 44100;
c->channels = 2;
+ c->sample_fmt = AV_SAMPLE_FMT_S16;
/* open it */
- if (avcodec_open(c, codec) < 0) {
+ if (avcodec_open2(c, codec, NULL) < 0) {
fprintf(stderr, "could not open codec\n");
exit(1);
}
c->max_b_frames=1;
c->pix_fmt = PIX_FMT_YUV420P;
+ if(codec_id == CODEC_ID_H264)
+ av_opt_set(c->priv_data, "preset", "slow", 0);
+
/* open it */
- if (avcodec_open(c, codec) < 0) {
+ if (avcodec_open2(c, codec, NULL) < 0) {
fprintf(stderr, "could not open codec\n");
exit(1);
}
s->i_tex_bits += get_bits_diff(s);
}
- static int amv_encode_picture(AVCodecContext *avctx,
- unsigned char *buf, int buf_size, void *data)
- {
+// maximum over s->mjpeg_vsample[i]
+#define V_MAX 2
- AVFrame* pic=data;
++static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
++ AVFrame *pic, int *got_packet)
+
- return ff_MPV_encode_picture(avctx,buf, buf_size, pic);
++{
+ MpegEncContext *s = avctx->priv_data;
+ int i;
+
+ //CODEC_FLAG_EMU_EDGE have to be cleared
+ if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)
+ return -1;
+
+ //picture should be flipped upside-down
+ for(i=0; i < 3; i++) {
+ pic->data[i] += (pic->linesize[i] * (s->mjpeg_vsample[i] * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
+ pic->linesize[i] *= -1;
+ }
++ return ff_MPV_encode_picture(avctx, pkt, pic, got_packet);
+}
+
AVCodec ff_mjpeg_encoder = {
.name = "mjpeg",
.type = AVMEDIA_TYPE_VIDEO,
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
};
- .encode = amv_encode_picture,
+
+AVCodec ff_amv_encoder = {
+ .name = "amv",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_AMV,
+ .priv_data_size = sizeof(MpegEncContext),
+ .init = ff_MPV_encode_init,
++ .encode2 = amv_encode_picture,
+ .close = ff_MPV_encode_end,
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("AMV Video"),
+};
return 0;
}
- int ff_MPV_encode_picture(AVCodecContext *avctx,
- unsigned char *buf, int buf_size, void *data)
+ int ff_MPV_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *pic_arg, int *got_packet)
{
MpegEncContext *s = avctx->priv_data;
- AVFrame *pic_arg = data;
- int i, stuffing_count;
+ int i, stuffing_count, ret;
int context_count = s->slice_context_count;
- (ret = ff_alloc_packet(pkt, s->mb_width*s->mb_height*MAX_MB_BYTES)) < 0)
+ if (!pkt->data &&
++ (ret = ff_alloc_packet(pkt, s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+10000)) < 0)
+ return ret;
+
for (i = 0; i < context_count; i++) {
int start_y = s->thread_context[i]->start_mb_y;
int end_y = s->thread_context[i]-> end_mb_y;
if(s->data_partitioning){
if( s->pb2 .buf_end - s->pb2 .buf - (put_bits_count(&s-> pb2)>>3) < MAX_MB_BYTES
|| s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){
-- av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
++ av_log(s->avctx, AV_LOG_ERROR, "encoded partitioned frame too large\n");
return -1;
}
}