| 1825 | } |
| 1826 | |
| 1827 | static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) |
| 1828 | { |
| 1829 | AVFrame *tmp; |
| 1830 | int ret; |
| 1831 | |
| 1832 | av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO); |
| 1833 | |
| 1834 | // make sure the discard flag does not persist |
| 1835 | frame->flags &= ~AV_FRAME_FLAG_DISCARD; |
| 1836 | |
| 1837 | if (frame->data[0] && (frame->width != avctx->width || frame->height != avctx->height || frame->format != avctx->pix_fmt)) { |
| 1838 | av_log(avctx, AV_LOG_WARNING, "Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n", |
| 1839 | frame->width, frame->height, av_get_pix_fmt_name(frame->format), avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt)); |
| 1840 | av_frame_unref(frame); |
| 1841 | } |
| 1842 | |
| 1843 | if (!frame->data[0]) |
| 1844 | return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF); |
| 1845 | |
| 1846 | av_frame_side_data_free(&frame->side_data, &frame->nb_side_data); |
| 1847 | |
| 1848 | if ((flags & FF_REGET_BUFFER_FLAG_READONLY) || av_frame_is_writable(frame)) |
| 1849 | return ff_decode_frame_props(avctx, frame); |
| 1850 | |
| 1851 | tmp = av_frame_alloc(); |
| 1852 | if (!tmp) |
| 1853 | return AVERROR(ENOMEM); |
| 1854 | |
| 1855 | av_frame_move_ref(tmp, frame); |
| 1856 | |
| 1857 | ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF); |
| 1858 | if (ret < 0) { |
| 1859 | av_frame_free(&tmp); |
| 1860 | return ret; |
| 1861 | } |
| 1862 | |
| 1863 | av_frame_copy(frame, tmp); |
| 1864 | av_frame_free(&tmp); |
| 1865 | |
| 1866 | return 0; |
| 1867 | } |
| 1868 | |
| 1869 | int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) |
| 1870 | { |
no test coverage detected