#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavcodec/audioconvert.h"
+#include "libavcodec/opt.h"
#include "cmdutils.h"
static VideoState *cur_stream;
static int64_t audio_callback_time;
-AVPacket flush_pkt;
+static AVPacket flush_pkt;
#define FF_ALLOC_EVENT (SDL_USEREVENT)
#define FF_REFRESH_EVENT (SDL_USEREVENT + 1)
#define FF_QUIT_EVENT (SDL_USEREVENT + 2)
-SDL_Surface *screen;
+static SDL_Surface *screen;
/* packet queue handling */
static void packet_queue_init(PacketQueue *q)
const uint32_t *pal;
int dstx, dsty, dstw, dsth;
- dstx = FFMIN(FFMAX(rect->x, 0), imgw);
- dstw = FFMIN(FFMAX(rect->w, 0), imgw - dstx);
- dsty = FFMIN(FFMAX(rect->y, 0), imgh);
- dsth = FFMIN(FFMAX(rect->h, 0), imgh - dsty);
+ dstw = av_clip(rect->w, 0, imgw);
+ dsth = av_clip(rect->h, 0, imgh);
+ dstx = av_clip(rect->x, 0, imgw - dstw);
+ dsty = av_clip(rect->y, 0, imgh - dsth);
lum = dst->data[0] + dsty * dst->linesize[0];
cb = dst->data[1] + (dsty >> 1) * dst->linesize[1];
cr = dst->data[2] + (dsty >> 1) * dst->linesize[2];
width2 = (dstw + 1) >> 1;
skip2 = dstx >> 1;
wrap = dst->linesize[0];
- wrap3 = rect->linesize;
- p = rect->bitmap;
- pal = rect->rgba_palette; /* Now in YCrCb! */
+ wrap3 = rect->pict.linesize[0];
+ p = rect->pict.data[0];
+ pal = (const uint32_t *)rect->pict.data[1]; /* Now in YCrCb! */
if (dsty & 1) {
lum += dstx;
for (i = 0; i < sp->sub.num_rects; i++)
{
- av_free(sp->sub.rects[i].bitmap);
- av_free(sp->sub.rects[i].rgba_palette);
+ av_freep(&sp->sub.rects[i]->pict.data[0]);
+ av_freep(&sp->sub.rects[i]->pict.data[1]);
+ av_freep(&sp->sub.rects[i]);
}
av_free(sp->sub.rects);
pict.linesize[2] = vp->bmp->pitches[1];
for (i = 0; i < sp->sub.num_rects; i++)
- blend_subrect(&pict, &sp->sub.rects[i],
+ blend_subrect(&pict, sp->sub.rects[i],
vp->bmp->w, vp->bmp->h);
SDL_UnlockYUVOverlay (vp->bmp);
/* compute nominal delay */
delay = vp->pts - is->frame_last_pts;
- if (delay <= 0 || delay >= 2.0) {
+ if (delay <= 0 || delay >= 10.0) {
/* if incorrect delay, use previous one */
delay = is->frame_last_delay;
}
pict.linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1];
+ sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
img_convert_ctx = sws_getCachedContext(img_convert_ctx,
is->video_st->codec->width, is->video_st->codec->height,
is->video_st->codec->pix_fmt,
for (i = 0; i < sp->sub.num_rects; i++)
{
- for (j = 0; j < sp->sub.rects[i].nb_colors; j++)
+ for (j = 0; j < sp->sub.rects[i]->nb_colors; j++)
{
- RGBA_IN(r, g, b, a, sp->sub.rects[i].rgba_palette + j);
+ RGBA_IN(r, g, b, a, (uint32_t*)sp->sub.rects[i]->pict.data[1] + j);
y = RGB_TO_Y_CCIR(r, g, b);
u = RGB_TO_U_CCIR(r, g, b, 0);
v = RGB_TO_V_CCIR(r, g, b, 0);
- YUVA_OUT(sp->sub.rects[i].rgba_palette + j, y, u, v, a);
+ YUVA_OUT((uint32_t*)sp->sub.rects[i]->pict.data[1] + j, y, u, v, a);
}
}
enc->skip_loop_filter= skip_loop_filter;
enc->error_recognition= error_recognition;
enc->error_concealment= error_concealment;
+
+ set_context_opts(enc, avctx_opts[enc->codec_type], 0);
+
if (!codec ||
avcodec_open(enc, codec) < 0)
return -1;
{ "ec", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&error_concealment}, "set error concealment options", "bit_mask" },
{ "sync", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
{ "threads", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
+ { "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
{ NULL, },
};
/* Called from the main */
int main(int argc, char **argv)
{
- int flags;
+ int flags, i;
/* register all codecs, demux and protocols */
avcodec_register_all();
avdevice_register_all();
av_register_all();
+ for(i=0; i<CODEC_TYPE_NB; i++){
+ avctx_opts[i]= avcodec_alloc_context2(i);
+ }
+ avformat_opts = av_alloc_format_context();
+ sws_opts = sws_getContext(16,16,0, 16,16,0, sws_flags, NULL,NULL,NULL);
+
show_banner();
parse_options(argc, argv, options, opt_input_file);
if (!input_filename) {
- show_help();
+ fprintf(stderr, "An input file must be specified\n");
exit(1);
}