* format handling
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#ifdef HAVE_AV_CONFIG_H
-#undef HAVE_AV_CONFIG_H
-#endif
+#include <math.h>
- #include <libavutil/imgutils.h>
-#include "libavcodec/avcodec.h"
-#include "libavutil/audioconvert.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/samplefmt.h"
+#include <libavutil/opt.h>
+#include <libavcodec/avcodec.h>
+#include <libavutil/audioconvert.h>
++#include <libavutil/imgutils.h>
+#include <libavutil/mathematics.h>
+#include <libavutil/samplefmt.h>
#define INBUF_SIZE 4096
#define AUDIO_INBUF_SIZE 20480
{
AVCodec *codec;
AVCodecContext *c= NULL;
- int i, out_size, x, y, outbuf_size;
+ int i, ret, x, y, got_output;
FILE *f;
AVFrame *picture;
- uint8_t *outbuf;
- int had_output=0;
+ AVPacket pkt;
+ uint8_t endcode[] = { 0, 0, 1, 0xb7 };
- printf("Video encoding\n");
+ printf("Encode video file %s\n", filename);
/* find the mpeg1 video encoder */
- codec = avcodec_find_encoder(AV_CODEC_ID_MPEG1VIDEO);
+ codec = avcodec_find_encoder(codec_id);
if (!codec) {
fprintf(stderr, "codec not found\n");
exit(1);
exit(1);
}
- /* alloc image and output buffer */
- outbuf_size = 100000 + 12*c->width*c->height;
- outbuf = malloc(outbuf_size);
-
+ /* the image can be allocated by any means and av_image_alloc() is
+ * just the most convenient way if av_malloc() is to be used */
- av_image_alloc(picture->data, picture->linesize,
- c->width, c->height, c->pix_fmt, 1);
+ ret = av_image_alloc(picture->data, picture->linesize, c->width, c->height,
+ c->pix_fmt, 32);
+ if (ret < 0) {
+ fprintf(stderr, "could not alloc raw picture buffer\n");
+ exit(1);
+ }
++
+ picture->format = c->pix_fmt;
+ picture->width = c->width;
+ picture->height = c->height;
/* encode 1 second of video */
for(i=0;i<25;i++) {
}
/* get the delayed frames */
- for(; out_size || !had_output; i++) {
+ for (got_output = 1; got_output; i++) {
fflush(stdout);
- out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
- had_output |= out_size;
- printf("write frame %3d (size=%5d)\n", i, out_size);
- fwrite(outbuf, 1, out_size, f);
+ ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
+ if (ret < 0) {
+ fprintf(stderr, "error encoding frame\n");
+ exit(1);
+ }
+
+ if (got_output) {
- printf("encoding frame %3d (size=%5d)\n", i, pkt.size);
++ printf("write frame %3d (size=%5d)\n", i, pkt.size);
+ fwrite(pkt.data, 1, pkt.size, f);
+ av_free_packet(&pkt);
+ }
}
/* add sequence end code to have a real mpeg file */
x86/simple_idct_mmx.o \
MMX-OBJS-$(CONFIG_AAC_DECODER) += x86/sbrdsp_init.o
- MMX-OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp_mmx.o
+ MMX-OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp_init.o
MMX-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp_mmx.o
MMX-OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhd_mmx.o
-MMX-OBJS-$(CONFIG_DWT) += x86/snowdsp_mmx.o
+MMX-OBJS-$(CONFIG_DWT) += x86/snowdsp_mmx.o \
+ x86/dwt.o
MMX-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o
- MMX-OBJS-$(CONFIG_FFT) += x86/fft.o
+ MMX-OBJS-$(CONFIG_FFT) += x86/fft_init.o
+MMX-OBJS-$(CONFIG_GPL) += x86/idct_mmx.o
- MMX-OBJS-$(CONFIG_H264DSP) += x86/h264dsp_mmx.o
+ MMX-OBJS-$(CONFIG_H264DSP) += x86/h264dsp_init.o
MMX-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o
MMX-OBJS-$(CONFIG_LPC) += x86/lpc_mmx.o
MMX-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/mpegaudiodec_mmx.o