| OLD | NEW |
| 1 /* | 1 /* |
| 2 * FFplay : Simple Media Player based on the FFmpeg libraries | 2 * FFplay : Simple Media Player based on the FFmpeg libraries |
| 3 * Copyright (c) 2003 Fabrice Bellard | 3 * Copyright (c) 2003 Fabrice Bellard |
| 4 * | 4 * |
| 5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
| 6 * | 6 * |
| 7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * FFmpeg is distributed in the hope that it will be useful, | 12 * FFmpeg is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Lesser General Public License for more details. | 15 * Lesser General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Lesser General Public | 17 * You should have received a copy of the GNU Lesser General Public |
| 18 * License along with FFmpeg; if not, write to the Free Software | 18 * License along with FFmpeg; if not, write to the Free Software |
| 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #define _XOPEN_SOURCE 600 |
| 23 |
| 22 #include "config.h" | 24 #include "config.h" |
| 23 #include <inttypes.h> | 25 #include <inttypes.h> |
| 24 #include <math.h> | 26 #include <math.h> |
| 25 #include <limits.h> | 27 #include <limits.h> |
| 26 #include "libavutil/avstring.h" | 28 #include "libavutil/avstring.h" |
| 27 #include "libavutil/colorspace.h" | 29 #include "libavutil/colorspace.h" |
| 28 #include "libavutil/pixdesc.h" | 30 #include "libavutil/pixdesc.h" |
| 31 #include "libavcore/imgutils.h" |
| 29 #include "libavcore/parseutils.h" | 32 #include "libavcore/parseutils.h" |
| 30 #include "libavformat/avformat.h" | 33 #include "libavformat/avformat.h" |
| 31 #include "libavdevice/avdevice.h" | 34 #include "libavdevice/avdevice.h" |
| 32 #include "libswscale/swscale.h" | 35 #include "libswscale/swscale.h" |
| 33 #include "libavcodec/audioconvert.h" | 36 #include "libavcodec/audioconvert.h" |
| 34 #include "libavcodec/opt.h" | 37 #include "libavcodec/opt.h" |
| 35 #include "libavcodec/avfft.h" | 38 #include "libavcodec/avfft.h" |
| 36 | 39 |
| 37 #if CONFIG_AVFILTER | 40 #if CONFIG_AVFILTER |
| 38 # include "libavfilter/avfilter.h" | 41 # include "libavfilter/avfilter.h" |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 SubPicture *sp; | 690 SubPicture *sp; |
| 688 AVPicture pict; | 691 AVPicture pict; |
| 689 float aspect_ratio; | 692 float aspect_ratio; |
| 690 int width, height, x, y; | 693 int width, height, x, y; |
| 691 SDL_Rect rect; | 694 SDL_Rect rect; |
| 692 int i; | 695 int i; |
| 693 | 696 |
| 694 vp = &is->pictq[is->pictq_rindex]; | 697 vp = &is->pictq[is->pictq_rindex]; |
| 695 if (vp->bmp) { | 698 if (vp->bmp) { |
| 696 #if CONFIG_AVFILTER | 699 #if CONFIG_AVFILTER |
| 697 if (vp->picref->pixel_aspect.num == 0) | 700 if (vp->picref->video->pixel_aspect.num == 0) |
| 698 aspect_ratio = 0; | 701 aspect_ratio = 0; |
| 699 else | 702 else |
| 700 aspect_ratio = av_q2d(vp->picref->pixel_aspect); | 703 aspect_ratio = av_q2d(vp->picref->video->pixel_aspect); |
| 701 #else | 704 #else |
| 702 | 705 |
| 703 /* XXX: use variable in the frame */ | 706 /* XXX: use variable in the frame */ |
| 704 if (is->video_st->sample_aspect_ratio.num) | 707 if (is->video_st->sample_aspect_ratio.num) |
| 705 aspect_ratio = av_q2d(is->video_st->sample_aspect_ratio); | 708 aspect_ratio = av_q2d(is->video_st->sample_aspect_ratio); |
| 706 else if (is->video_st->codec->sample_aspect_ratio.num) | 709 else if (is->video_st->codec->sample_aspect_ratio.num) |
| 707 aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio); | 710 aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio); |
| 708 else | 711 else |
| 709 aspect_ratio = 0; | 712 aspect_ratio = 0; |
| 710 #endif | 713 #endif |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 if (is->audio_st && is->video_st) | 1286 if (is->audio_st && is->video_st) |
| 1284 av_diff = get_audio_clock(is) - get_video_clock(is); | 1287 av_diff = get_audio_clock(is) - get_video_clock(is); |
| 1285 printf("%7.2f A-V:%7.3f s:%3.1f aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64
"/%"PRId64" \r", | 1288 printf("%7.2f A-V:%7.3f s:%3.1f aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64
"/%"PRId64" \r", |
| 1286 get_master_clock(is), av_diff, FFMAX(is->skip_frames-1, 0), a
qsize / 1024, vqsize / 1024, sqsize, is->faulty_dts, is->faulty_pts); | 1289 get_master_clock(is), av_diff, FFMAX(is->skip_frames-1, 0), a
qsize / 1024, vqsize / 1024, sqsize, is->faulty_dts, is->faulty_pts); |
| 1287 fflush(stdout); | 1290 fflush(stdout); |
| 1288 last_time = cur_time; | 1291 last_time = cur_time; |
| 1289 } | 1292 } |
| 1290 } | 1293 } |
| 1291 } | 1294 } |
| 1292 | 1295 |
| 1296 static void stream_close(VideoState *is) |
| 1297 { |
| 1298 VideoPicture *vp; |
| 1299 int i; |
| 1300 /* XXX: use a special url_shutdown call to abort parse cleanly */ |
| 1301 is->abort_request = 1; |
| 1302 SDL_WaitThread(is->parse_tid, NULL); |
| 1303 SDL_WaitThread(is->refresh_tid, NULL); |
| 1304 |
| 1305 /* free all pictures */ |
| 1306 for(i=0;i<VIDEO_PICTURE_QUEUE_SIZE; i++) { |
| 1307 vp = &is->pictq[i]; |
| 1308 #if CONFIG_AVFILTER |
| 1309 if (vp->picref) { |
| 1310 avfilter_unref_buffer(vp->picref); |
| 1311 vp->picref = NULL; |
| 1312 } |
| 1313 #endif |
| 1314 if (vp->bmp) { |
| 1315 SDL_FreeYUVOverlay(vp->bmp); |
| 1316 vp->bmp = NULL; |
| 1317 } |
| 1318 } |
| 1319 SDL_DestroyMutex(is->pictq_mutex); |
| 1320 SDL_DestroyCond(is->pictq_cond); |
| 1321 SDL_DestroyMutex(is->subpq_mutex); |
| 1322 SDL_DestroyCond(is->subpq_cond); |
| 1323 #if !CONFIG_AVFILTER |
| 1324 if (is->img_convert_ctx) |
| 1325 sws_freeContext(is->img_convert_ctx); |
| 1326 #endif |
| 1327 av_free(is); |
| 1328 } |
| 1329 |
| 1330 static void do_exit(void) |
| 1331 { |
| 1332 int i; |
| 1333 if (cur_stream) { |
| 1334 stream_close(cur_stream); |
| 1335 cur_stream = NULL; |
| 1336 } |
| 1337 for (i = 0; i < AVMEDIA_TYPE_NB; i++) |
| 1338 av_free(avcodec_opts[i]); |
| 1339 av_free(avformat_opts); |
| 1340 av_free(sws_opts); |
| 1341 #if CONFIG_AVFILTER |
| 1342 avfilter_uninit(); |
| 1343 #endif |
| 1344 if (show_status) |
| 1345 printf("\n"); |
| 1346 SDL_Quit(); |
| 1347 exit(0); |
| 1348 } |
| 1349 |
| 1293 /* allocate a picture (needs to do that in main thread to avoid | 1350 /* allocate a picture (needs to do that in main thread to avoid |
| 1294 potential locking problems */ | 1351 potential locking problems */ |
| 1295 static void alloc_picture(void *opaque) | 1352 static void alloc_picture(void *opaque) |
| 1296 { | 1353 { |
| 1297 VideoState *is = opaque; | 1354 VideoState *is = opaque; |
| 1298 VideoPicture *vp; | 1355 VideoPicture *vp; |
| 1299 | 1356 |
| 1300 vp = &is->pictq[is->pictq_windex]; | 1357 vp = &is->pictq[is->pictq_windex]; |
| 1301 | 1358 |
| 1302 if (vp->bmp) | 1359 if (vp->bmp) |
| 1303 SDL_FreeYUVOverlay(vp->bmp); | 1360 SDL_FreeYUVOverlay(vp->bmp); |
| 1304 | 1361 |
| 1305 #if CONFIG_AVFILTER | 1362 #if CONFIG_AVFILTER |
| 1306 if (vp->picref) | 1363 if (vp->picref) |
| 1307 avfilter_unref_buffer(vp->picref); | 1364 avfilter_unref_buffer(vp->picref); |
| 1308 vp->picref = NULL; | 1365 vp->picref = NULL; |
| 1309 | 1366 |
| 1310 vp->width = is->out_video_filter->inputs[0]->w; | 1367 vp->width = is->out_video_filter->inputs[0]->w; |
| 1311 vp->height = is->out_video_filter->inputs[0]->h; | 1368 vp->height = is->out_video_filter->inputs[0]->h; |
| 1312 vp->pix_fmt = is->out_video_filter->inputs[0]->format; | 1369 vp->pix_fmt = is->out_video_filter->inputs[0]->format; |
| 1313 #else | 1370 #else |
| 1314 vp->width = is->video_st->codec->width; | 1371 vp->width = is->video_st->codec->width; |
| 1315 vp->height = is->video_st->codec->height; | 1372 vp->height = is->video_st->codec->height; |
| 1316 vp->pix_fmt = is->video_st->codec->pix_fmt; | 1373 vp->pix_fmt = is->video_st->codec->pix_fmt; |
| 1317 #endif | 1374 #endif |
| 1318 | 1375 |
| 1319 vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height, | 1376 vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height, |
| 1320 SDL_YV12_OVERLAY, | 1377 SDL_YV12_OVERLAY, |
| 1321 screen); | 1378 screen); |
| 1379 if (!vp->bmp || vp->bmp->pitches[0] < vp->width) { |
| 1380 /* SDL allocates a buffer smaller than requested if the video |
| 1381 * overlay hardware is unable to support the requested size. */ |
| 1382 fprintf(stderr, "Error: the video system does not support an image\n" |
| 1383 "size of %dx%d pixels. Try using -lowres or -vf \"scale=
w:h\"\n" |
| 1384 "to reduce the image size.\n", vp->width, vp->height ); |
| 1385 do_exit(); |
| 1386 } |
| 1322 | 1387 |
| 1323 SDL_LockMutex(is->pictq_mutex); | 1388 SDL_LockMutex(is->pictq_mutex); |
| 1324 vp->allocated = 1; | 1389 vp->allocated = 1; |
| 1325 SDL_CondSignal(is->pictq_cond); | 1390 SDL_CondSignal(is->pictq_cond); |
| 1326 SDL_UnlockMutex(is->pictq_mutex); | 1391 SDL_UnlockMutex(is->pictq_mutex); |
| 1327 } | 1392 } |
| 1328 | 1393 |
| 1329 /** | 1394 /** |
| 1330 * | 1395 * |
| 1331 * @param pts the dts of the pkt / pts of the frame and guessed if not known | 1396 * @param pts the dts of the pkt / pts of the frame and guessed if not known |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 w = codec->width; | 1640 w = codec->width; |
| 1576 h = codec->height; | 1641 h = codec->height; |
| 1577 avcodec_align_dimensions2(codec, &w, &h, stride); | 1642 avcodec_align_dimensions2(codec, &w, &h, stride); |
| 1578 edge = codec->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width(); | 1643 edge = codec->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width(); |
| 1579 w += edge << 1; | 1644 w += edge << 1; |
| 1580 h += edge << 1; | 1645 h += edge << 1; |
| 1581 | 1646 |
| 1582 if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h))) | 1647 if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h))) |
| 1583 return -1; | 1648 return -1; |
| 1584 | 1649 |
| 1585 ref->w = codec->width; | 1650 ref->video->w = codec->width; |
| 1586 ref->h = codec->height; | 1651 ref->video->h = codec->height; |
| 1587 for(i = 0; i < 4; i ++) { | 1652 for(i = 0; i < 4; i ++) { |
| 1588 unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->forma
t].log2_chroma_w : 0; | 1653 unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->forma
t].log2_chroma_w : 0; |
| 1589 unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->forma
t].log2_chroma_h : 0; | 1654 unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->forma
t].log2_chroma_h : 0; |
| 1590 | 1655 |
| 1591 if (ref->data[i]) { | 1656 if (ref->data[i]) { |
| 1592 ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >>
vshift); | 1657 ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >>
vshift); |
| 1593 } | 1658 } |
| 1594 pic->data[i] = ref->data[i]; | 1659 pic->data[i] = ref->data[i]; |
| 1595 pic->linesize[i] = ref->linesize[i]; | 1660 pic->linesize[i] = ref->linesize[i]; |
| 1596 } | 1661 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1609 | 1674 |
| 1610 static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic) | 1675 static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic) |
| 1611 { | 1676 { |
| 1612 AVFilterBufferRef *ref = pic->opaque; | 1677 AVFilterBufferRef *ref = pic->opaque; |
| 1613 | 1678 |
| 1614 if (pic->data[0] == NULL) { | 1679 if (pic->data[0] == NULL) { |
| 1615 pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; | 1680 pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; |
| 1616 return codec->get_buffer(codec, pic); | 1681 return codec->get_buffer(codec, pic); |
| 1617 } | 1682 } |
| 1618 | 1683 |
| 1619 if ((codec->width != ref->w) || (codec->height != ref->h) || | 1684 if ((codec->width != ref->video->w) || (codec->height != ref->video->h) || |
| 1620 (codec->pix_fmt != ref->format)) { | 1685 (codec->pix_fmt != ref->format)) { |
| 1621 av_log(codec, AV_LOG_ERROR, "Picture properties changed.\n"); | 1686 av_log(codec, AV_LOG_ERROR, "Picture properties changed.\n"); |
| 1622 return -1; | 1687 return -1; |
| 1623 } | 1688 } |
| 1624 | 1689 |
| 1625 pic->reordered_opaque = codec->reordered_opaque; | 1690 pic->reordered_opaque = codec->reordered_opaque; |
| 1626 return 0; | 1691 return 0; |
| 1627 } | 1692 } |
| 1628 | 1693 |
| 1629 static int input_init(AVFilterContext *ctx, const char *args, void *opaque) | 1694 static int input_init(AVFilterContext *ctx, const char *args, void *opaque) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 | 1728 |
| 1664 while (!(ret = get_video_frame(priv->is, priv->frame, &pts, &pkt))) | 1729 while (!(ret = get_video_frame(priv->is, priv->frame, &pts, &pkt))) |
| 1665 av_free_packet(&pkt); | 1730 av_free_packet(&pkt); |
| 1666 if (ret < 0) | 1731 if (ret < 0) |
| 1667 return -1; | 1732 return -1; |
| 1668 | 1733 |
| 1669 if(priv->use_dr1) { | 1734 if(priv->use_dr1) { |
| 1670 picref = avfilter_ref_buffer(priv->frame->opaque, ~0); | 1735 picref = avfilter_ref_buffer(priv->frame->opaque, ~0); |
| 1671 } else { | 1736 } else { |
| 1672 picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, link->w, link->h
); | 1737 picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, link->w, link->h
); |
| 1673 av_picture_copy((AVPicture *)&picref->data, (AVPicture *)priv->frame, | 1738 av_image_copy(picref->data, picref->linesize, |
| 1674 picref->format, link->w, link->h); | 1739 priv->frame->data, priv->frame->linesize, |
| 1740 picref->format, link->w, link->h); |
| 1675 } | 1741 } |
| 1676 av_free_packet(&pkt); | 1742 av_free_packet(&pkt); |
| 1677 | 1743 |
| 1678 picref->pts = pts; | 1744 picref->pts = pts; |
| 1679 picref->pos = pkt.pos; | 1745 picref->pos = pkt.pos; |
| 1680 picref->pixel_aspect = priv->is->video_st->codec->sample_aspect_ratio; | 1746 picref->video->pixel_aspect = priv->is->video_st->codec->sample_aspect_ratio
; |
| 1681 avfilter_start_frame(link, picref); | 1747 avfilter_start_frame(link, picref); |
| 1682 avfilter_draw_slice(link, 0, link->h, 1); | 1748 avfilter_draw_slice(link, 0, link->h, 1); |
| 1683 avfilter_end_frame(link); | 1749 avfilter_end_frame(link); |
| 1684 | 1750 |
| 1685 return 0; | 1751 return 0; |
| 1686 } | 1752 } |
| 1687 | 1753 |
| 1688 static int input_query_formats(AVFilterContext *ctx) | 1754 static int input_query_formats(AVFilterContext *ctx) |
| 1689 { | 1755 { |
| 1690 FilterPriv *priv = ctx->priv; | 1756 FilterPriv *priv = ctx->priv; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1783 int ret; | 1849 int ret; |
| 1784 | 1850 |
| 1785 #if CONFIG_AVFILTER | 1851 #if CONFIG_AVFILTER |
| 1786 int64_t pos; | 1852 int64_t pos; |
| 1787 char sws_flags_str[128]; | 1853 char sws_flags_str[128]; |
| 1788 AVFilterContext *filt_src = NULL, *filt_out = NULL; | 1854 AVFilterContext *filt_src = NULL, *filt_out = NULL; |
| 1789 AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph)); | 1855 AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph)); |
| 1790 snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags); | 1856 snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags); |
| 1791 graph->scale_sws_opts = av_strdup(sws_flags_str); | 1857 graph->scale_sws_opts = av_strdup(sws_flags_str); |
| 1792 | 1858 |
| 1793 if(!(filt_src = avfilter_open(&input_filter, "src"))) goto the_end; | 1859 if (avfilter_open(&filt_src, &input_filter, "src") < 0) goto the_end; |
| 1794 if(!(filt_out = avfilter_open(&output_filter, "out"))) goto the_end; | 1860 if (avfilter_open(&filt_out, &output_filter, "out") < 0) goto the_end; |
| 1795 | 1861 |
| 1796 if(avfilter_init_filter(filt_src, NULL, is)) goto the_end; | 1862 if(avfilter_init_filter(filt_src, NULL, is)) goto the_end; |
| 1797 if(avfilter_init_filter(filt_out, NULL, frame)) goto the_end; | 1863 if(avfilter_init_filter(filt_out, NULL, frame)) goto the_end; |
| 1798 | 1864 |
| 1799 | 1865 |
| 1800 if(vfilters) { | 1866 if(vfilters) { |
| 1801 AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut)); | 1867 AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut)); |
| 1802 AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut)); | 1868 AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut)); |
| 1803 | 1869 |
| 1804 outputs->name = av_strdup("in"); | 1870 outputs->name = av_strdup("in"); |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2651 | 2717 |
| 2652 is->av_sync_type = av_sync_type; | 2718 is->av_sync_type = av_sync_type; |
| 2653 is->parse_tid = SDL_CreateThread(decode_thread, is); | 2719 is->parse_tid = SDL_CreateThread(decode_thread, is); |
| 2654 if (!is->parse_tid) { | 2720 if (!is->parse_tid) { |
| 2655 av_free(is); | 2721 av_free(is); |
| 2656 return NULL; | 2722 return NULL; |
| 2657 } | 2723 } |
| 2658 return is; | 2724 return is; |
| 2659 } | 2725 } |
| 2660 | 2726 |
| 2661 static void stream_close(VideoState *is) | |
| 2662 { | |
| 2663 VideoPicture *vp; | |
| 2664 int i; | |
| 2665 /* XXX: use a special url_shutdown call to abort parse cleanly */ | |
| 2666 is->abort_request = 1; | |
| 2667 SDL_WaitThread(is->parse_tid, NULL); | |
| 2668 SDL_WaitThread(is->refresh_tid, NULL); | |
| 2669 | |
| 2670 /* free all pictures */ | |
| 2671 for(i=0;i<VIDEO_PICTURE_QUEUE_SIZE; i++) { | |
| 2672 vp = &is->pictq[i]; | |
| 2673 #if CONFIG_AVFILTER | |
| 2674 if (vp->picref) { | |
| 2675 avfilter_unref_buffer(vp->picref); | |
| 2676 vp->picref = NULL; | |
| 2677 } | |
| 2678 #endif | |
| 2679 if (vp->bmp) { | |
| 2680 SDL_FreeYUVOverlay(vp->bmp); | |
| 2681 vp->bmp = NULL; | |
| 2682 } | |
| 2683 } | |
| 2684 SDL_DestroyMutex(is->pictq_mutex); | |
| 2685 SDL_DestroyCond(is->pictq_cond); | |
| 2686 SDL_DestroyMutex(is->subpq_mutex); | |
| 2687 SDL_DestroyCond(is->subpq_cond); | |
| 2688 #if !CONFIG_AVFILTER | |
| 2689 if (is->img_convert_ctx) | |
| 2690 sws_freeContext(is->img_convert_ctx); | |
| 2691 #endif | |
| 2692 av_free(is); | |
| 2693 } | |
| 2694 | |
| 2695 static void stream_cycle_channel(VideoState *is, int codec_type) | 2727 static void stream_cycle_channel(VideoState *is, int codec_type) |
| 2696 { | 2728 { |
| 2697 AVFormatContext *ic = is->ic; | 2729 AVFormatContext *ic = is->ic; |
| 2698 int start_index, stream_index; | 2730 int start_index, stream_index; |
| 2699 AVStream *st; | 2731 AVStream *st; |
| 2700 | 2732 |
| 2701 if (codec_type == AVMEDIA_TYPE_VIDEO) | 2733 if (codec_type == AVMEDIA_TYPE_VIDEO) |
| 2702 start_index = is->video_stream; | 2734 start_index = is->video_stream; |
| 2703 else if (codec_type == AVMEDIA_TYPE_AUDIO) | 2735 else if (codec_type == AVMEDIA_TYPE_AUDIO) |
| 2704 start_index = is->audio_stream; | 2736 start_index = is->audio_stream; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2762 static void step_to_next_frame(void) | 2794 static void step_to_next_frame(void) |
| 2763 { | 2795 { |
| 2764 if (cur_stream) { | 2796 if (cur_stream) { |
| 2765 /* if the stream is paused unpause it, then step */ | 2797 /* if the stream is paused unpause it, then step */ |
| 2766 if (cur_stream->paused) | 2798 if (cur_stream->paused) |
| 2767 stream_pause(cur_stream); | 2799 stream_pause(cur_stream); |
| 2768 } | 2800 } |
| 2769 step = 1; | 2801 step = 1; |
| 2770 } | 2802 } |
| 2771 | 2803 |
| 2772 static void do_exit(void) | |
| 2773 { | |
| 2774 int i; | |
| 2775 if (cur_stream) { | |
| 2776 stream_close(cur_stream); | |
| 2777 cur_stream = NULL; | |
| 2778 } | |
| 2779 for (i = 0; i < AVMEDIA_TYPE_NB; i++) | |
| 2780 av_free(avcodec_opts[i]); | |
| 2781 av_free(avformat_opts); | |
| 2782 av_free(sws_opts); | |
| 2783 #if CONFIG_AVFILTER | |
| 2784 avfilter_uninit(); | |
| 2785 #endif | |
| 2786 if (show_status) | |
| 2787 printf("\n"); | |
| 2788 SDL_Quit(); | |
| 2789 exit(0); | |
| 2790 } | |
| 2791 | |
| 2792 static void toggle_audio_display(void) | 2804 static void toggle_audio_display(void) |
| 2793 { | 2805 { |
| 2794 if (cur_stream) { | 2806 if (cur_stream) { |
| 2795 int bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); | 2807 int bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); |
| 2796 cur_stream->show_audio = (cur_stream->show_audio + 1) % 3; | 2808 cur_stream->show_audio = (cur_stream->show_audio + 1) % 3; |
| 2797 fill_rectangle(screen, | 2809 fill_rectangle(screen, |
| 2798 cur_stream->xleft, cur_stream->ytop, cur_stream->width, cur_
stream->height, | 2810 cur_stream->xleft, cur_stream->ytop, cur_stream->width, cur_
stream->height, |
| 2799 bgcolor); | 2811 bgcolor); |
| 2800 SDL_UpdateRect(screen, cur_stream->xleft, cur_stream->ytop, cur_stream->
width, cur_stream->height); | 2812 SDL_UpdateRect(screen, cur_stream->xleft, cur_stream->ytop, cur_stream->
width, cur_stream->height); |
| 2801 } | 2813 } |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3185 flush_pkt.data= "FLUSH"; | 3197 flush_pkt.data= "FLUSH"; |
| 3186 | 3198 |
| 3187 cur_stream = stream_open(input_filename, file_iformat); | 3199 cur_stream = stream_open(input_filename, file_iformat); |
| 3188 | 3200 |
| 3189 event_loop(); | 3201 event_loop(); |
| 3190 | 3202 |
| 3191 /* never returns */ | 3203 /* never returns */ |
| 3192 | 3204 |
| 3193 return 0; | 3205 return 0; |
| 3194 } | 3206 } |
| OLD | NEW |