X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffplay.c;h=4f8a803b9c9a80870b30872fc00a076dedafd719;hb=25bd48bdb46fc136b6991e496aaacc5caf07b577;hp=5bb3e09af13c657aa5c3c04d823927966414c00e;hpb=047599a4ba6352b2b5911c10fbec821ef6612d95;p=ffmpeg diff --git a/ffplay.c b/ffplay.c index 5bb3e09af13..4f8a803b9c9 100644 --- a/ffplay.c +++ b/ffplay.c @@ -27,6 +27,7 @@ #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" #include "libavcodec/audioconvert.h" +#include "libavcodec/opt.h" #include "cmdutils.h" @@ -216,13 +217,13 @@ static int is_full_screen; 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) @@ -440,10 +441,10 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, 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]; @@ -451,9 +452,9 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, 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; @@ -635,8 +636,9 @@ static void free_subpicture(SubPicture *sp) 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); @@ -720,7 +722,7 @@ static void video_image_display(VideoState *is) 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); @@ -1023,7 +1025,7 @@ static void video_refresh_timer(void *opaque) /* 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; } @@ -1267,6 +1269,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts) 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, @@ -1433,13 +1436,13 @@ static int subtitle_thread(void *arg) 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); } } @@ -1736,6 +1739,9 @@ static int stream_component_open(VideoState *is, int stream_index) 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; @@ -2493,6 +2499,7 @@ static const OptionDef options[] = { { "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, }, }; @@ -2529,19 +2536,25 @@ static void opt_input_file(const char *filename) /* 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