Merged-by: James Almer <jamrial@gmail.com>
James Almer authored on 2016/06/27 03:14:17... | ... |
@@ -2,6 +2,10 @@ Entries are sorted chronologically from oldest to youngest within each release, |
2 | 2 |
releases are sorted from youngest to oldest. |
3 | 3 |
|
4 | 4 |
version <next>: |
5 |
+- YUY2 Lossless Codec decoder |
|
6 |
+ |
|
7 |
+ |
|
8 |
+version 3.1: |
|
5 | 9 |
- DXVA2-accelerated HEVC Main10 decoding |
6 | 10 |
- fieldhint filter |
7 | 11 |
- loop video filter and aloop audio filter |
... | ... |
@@ -184,7 +184,7 @@ clean:: |
184 | 184 |
|
185 | 185 |
distclean:: |
186 | 186 |
$(RM) $(DISTCLEANSUFFIXES) |
187 |
- $(RM) config.* .config libavutil/avconfig.h .version avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h libavcodec/bsf_list.c libavformat/protocol_list.c |
|
187 |
+ $(RM) config.* .config libavutil/avconfig.h .version mapfile avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h libavcodec/bsf_list.c libavformat/protocol_list.c |
|
188 | 188 |
ifeq ($(SRC_LINK),src) |
189 | 189 |
$(RM) src |
190 | 190 |
endif |
... | ... |
@@ -5970,8 +5970,7 @@ enabled vdpau && |
5970 | 5970 |
disable vdpau |
5971 | 5971 |
|
5972 | 5972 |
enabled vdpau && enabled xlib && |
5973 |
- check_func_headers "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau && |
|
5974 |
- prepend ffmpeg_libs $($ldflags_filter "-lvdpau") && |
|
5973 |
+ check_lib2 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau && |
|
5975 | 5974 |
enable vdpau_x11 |
5976 | 5975 |
|
5977 | 5976 |
# Funny iconv installations are not unusual, so check it after all flags have been set |
... | ... |
@@ -15,6 +15,12 @@ libavutil: 2015-08-28 |
15 | 15 |
|
16 | 16 |
API changes, most recent first: |
17 | 17 |
|
18 |
+2016-06-26 - xxxxxxx / 1c9e861 - lavu 55.27.100 / 55.13.0 - hwcontext.h |
|
19 |
+ Add av_hwdevice_ctx_create(). |
|
20 |
+ |
|
21 |
+2016-06-26 - xxxxxxx / e47b8bb - lavc 57.48.101 / 57.19.1 - avcodec.h |
|
22 |
+ Adjust values for JPEG 2000 profiles. |
|
23 |
+ |
|
18 | 24 |
-------- 8< --------- FFmpeg 3.1 was cut here -------- 8< --------- |
19 | 25 |
|
20 | 26 |
2016-06-23 - 5d75e46 / db7968b - lavf 57.40.100 / 57.7.0 - avio.h |
... | ... |
@@ -61,9 +61,6 @@ DEFINE_GUID(DXVA2_ModeVP9_VLD_Profile0, 0x463707f8, 0xa1d0,0x4585,0x87,0x6d,0x83 |
61 | 61 |
DEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); |
62 | 62 |
DEFINE_GUID(GUID_NULL, 0x00000000, 0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); |
63 | 63 |
|
64 |
-typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT); |
|
65 |
-typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **); |
|
66 |
- |
|
67 | 64 |
typedef struct dxva2_mode { |
68 | 65 |
const GUID *guid; |
69 | 66 |
enum AVCodecID codec; |
... | ... |
@@ -96,16 +93,6 @@ static const dxva2_mode dxva2_modes[] = { |
96 | 96 |
{ NULL, 0 }, |
97 | 97 |
}; |
98 | 98 |
|
99 |
-typedef struct DXVA2DevicePriv { |
|
100 |
- HMODULE d3dlib; |
|
101 |
- HMODULE dxva2lib; |
|
102 |
- |
|
103 |
- HANDLE deviceHandle; |
|
104 |
- |
|
105 |
- IDirect3D9 *d3d9; |
|
106 |
- IDirect3DDevice9 *d3d9device; |
|
107 |
-} DXVA2DevicePriv; |
|
108 |
- |
|
109 | 99 |
typedef struct DXVA2Context { |
110 | 100 |
IDirectXVideoDecoder *decoder; |
111 | 101 |
|
... | ... |
@@ -119,32 +106,6 @@ typedef struct DXVA2Context { |
119 | 119 |
AVBufferRef *hw_frames_ctx; |
120 | 120 |
} DXVA2Context; |
121 | 121 |
|
122 |
-static void dxva2_device_uninit(AVHWDeviceContext *ctx) |
|
123 |
-{ |
|
124 |
- AVDXVA2DeviceContext *hwctx = ctx->hwctx; |
|
125 |
- DXVA2DevicePriv *priv = ctx->user_opaque; |
|
126 |
- |
|
127 |
- if (hwctx->devmgr && priv->deviceHandle != INVALID_HANDLE_VALUE) |
|
128 |
- IDirect3DDeviceManager9_CloseDeviceHandle(hwctx->devmgr, priv->deviceHandle); |
|
129 |
- |
|
130 |
- if (hwctx->devmgr) |
|
131 |
- IDirect3DDeviceManager9_Release(hwctx->devmgr); |
|
132 |
- |
|
133 |
- if (priv->d3d9device) |
|
134 |
- IDirect3DDevice9_Release(priv->d3d9device); |
|
135 |
- |
|
136 |
- if (priv->d3d9) |
|
137 |
- IDirect3D9_Release(priv->d3d9); |
|
138 |
- |
|
139 |
- if (priv->d3dlib) |
|
140 |
- FreeLibrary(priv->d3dlib); |
|
141 |
- |
|
142 |
- if (priv->dxva2lib) |
|
143 |
- FreeLibrary(priv->dxva2lib); |
|
144 |
- |
|
145 |
- av_freep(&ctx->user_opaque); |
|
146 |
-} |
|
147 |
- |
|
148 | 122 |
static void dxva2_uninit(AVCodecContext *s) |
149 | 123 |
{ |
150 | 124 |
InputStream *ist = s->opaque; |
... | ... |
@@ -201,17 +162,11 @@ static int dxva2_alloc(AVCodecContext *s) |
201 | 201 |
InputStream *ist = s->opaque; |
202 | 202 |
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; |
203 | 203 |
DXVA2Context *ctx; |
204 |
- pDirect3DCreate9 *createD3D = NULL; |
|
205 |
- pCreateDeviceManager9 *createDeviceManager = NULL; |
|
204 |
+ HANDLE device_handle; |
|
206 | 205 |
HRESULT hr; |
207 |
- D3DPRESENT_PARAMETERS d3dpp = {0}; |
|
208 |
- D3DDISPLAYMODE d3ddm; |
|
209 |
- unsigned resetToken = 0; |
|
210 |
- UINT adapter = D3DADAPTER_DEFAULT; |
|
211 | 206 |
|
212 | 207 |
AVHWDeviceContext *device_ctx; |
213 | 208 |
AVDXVA2DeviceContext *device_hwctx; |
214 |
- DXVA2DevicePriv *device_priv; |
|
215 | 209 |
int ret; |
216 | 210 |
|
217 | 211 |
ctx = av_mallocz(sizeof(*ctx)); |
... | ... |
@@ -223,102 +178,29 @@ static int dxva2_alloc(AVCodecContext *s) |
223 | 223 |
ist->hwaccel_get_buffer = dxva2_get_buffer; |
224 | 224 |
ist->hwaccel_retrieve_data = dxva2_retrieve_data; |
225 | 225 |
|
226 |
- ctx->hw_device_ctx = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_DXVA2); |
|
227 |
- if (!ctx->hw_device_ctx) |
|
226 |
+ ret = av_hwdevice_ctx_create(&ctx->hw_device_ctx, AV_HWDEVICE_TYPE_DXVA2, |
|
227 |
+ ist->hwaccel_device, NULL, 0); |
|
228 |
+ if (ret < 0) |
|
228 | 229 |
goto fail; |
229 |
- |
|
230 | 230 |
device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data; |
231 | 231 |
device_hwctx = device_ctx->hwctx; |
232 | 232 |
|
233 |
- device_priv = av_mallocz(sizeof(*device_priv)); |
|
234 |
- if (!device_priv) |
|
235 |
- goto fail; |
|
236 |
- |
|
237 |
- device_ctx->user_opaque = device_priv; |
|
238 |
- device_ctx->free = dxva2_device_uninit; |
|
239 |
- |
|
240 |
- device_priv->deviceHandle = INVALID_HANDLE_VALUE; |
|
241 |
- |
|
242 |
- device_priv->d3dlib = LoadLibrary("d3d9.dll"); |
|
243 |
- if (!device_priv->d3dlib) { |
|
244 |
- av_log(NULL, loglevel, "Failed to load D3D9 library\n"); |
|
245 |
- goto fail; |
|
246 |
- } |
|
247 |
- device_priv->dxva2lib = LoadLibrary("dxva2.dll"); |
|
248 |
- if (!device_priv->dxva2lib) { |
|
249 |
- av_log(NULL, loglevel, "Failed to load DXVA2 library\n"); |
|
250 |
- goto fail; |
|
251 |
- } |
|
252 |
- |
|
253 |
- createD3D = (pDirect3DCreate9 *)GetProcAddress(device_priv->d3dlib, "Direct3DCreate9"); |
|
254 |
- if (!createD3D) { |
|
255 |
- av_log(NULL, loglevel, "Failed to locate Direct3DCreate9\n"); |
|
256 |
- goto fail; |
|
257 |
- } |
|
258 |
- createDeviceManager = (pCreateDeviceManager9 *)GetProcAddress(device_priv->dxva2lib, "DXVA2CreateDirect3DDeviceManager9"); |
|
259 |
- if (!createDeviceManager) { |
|
260 |
- av_log(NULL, loglevel, "Failed to locate DXVA2CreateDirect3DDeviceManager9\n"); |
|
261 |
- goto fail; |
|
262 |
- } |
|
263 |
- |
|
264 |
- device_priv->d3d9 = createD3D(D3D_SDK_VERSION); |
|
265 |
- if (!device_priv->d3d9) { |
|
266 |
- av_log(NULL, loglevel, "Failed to create IDirect3D object\n"); |
|
267 |
- goto fail; |
|
268 |
- } |
|
269 |
- |
|
270 |
- if (ist->hwaccel_device) { |
|
271 |
- adapter = atoi(ist->hwaccel_device); |
|
272 |
- av_log(NULL, AV_LOG_INFO, "Using HWAccel device %d\n", adapter); |
|
273 |
- } |
|
274 |
- |
|
275 |
- IDirect3D9_GetAdapterDisplayMode(device_priv->d3d9, adapter, &d3ddm); |
|
276 |
- d3dpp.Windowed = TRUE; |
|
277 |
- d3dpp.BackBufferWidth = 640; |
|
278 |
- d3dpp.BackBufferHeight = 480; |
|
279 |
- d3dpp.BackBufferCount = 0; |
|
280 |
- d3dpp.BackBufferFormat = d3ddm.Format; |
|
281 |
- d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; |
|
282 |
- d3dpp.Flags = D3DPRESENTFLAG_VIDEO; |
|
283 |
- |
|
284 |
- hr = IDirect3D9_CreateDevice(device_priv->d3d9, adapter, D3DDEVTYPE_HAL, GetDesktopWindow(), |
|
285 |
- D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, |
|
286 |
- &d3dpp, &device_priv->d3d9device); |
|
287 |
- if (FAILED(hr)) { |
|
288 |
- av_log(NULL, loglevel, "Failed to create Direct3D device\n"); |
|
289 |
- goto fail; |
|
290 |
- } |
|
291 |
- |
|
292 |
- hr = createDeviceManager(&resetToken, &device_hwctx->devmgr); |
|
233 |
+ hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr, |
|
234 |
+ &device_handle); |
|
293 | 235 |
if (FAILED(hr)) { |
294 |
- av_log(NULL, loglevel, "Failed to create Direct3D device manager\n"); |
|
236 |
+ av_log(NULL, loglevel, "Failed to open a device handle\n"); |
|
295 | 237 |
goto fail; |
296 | 238 |
} |
297 | 239 |
|
298 |
- hr = IDirect3DDeviceManager9_ResetDevice(device_hwctx->devmgr, device_priv->d3d9device, resetToken); |
|
299 |
- if (FAILED(hr)) { |
|
300 |
- av_log(NULL, loglevel, "Failed to bind Direct3D device to device manager\n"); |
|
301 |
- goto fail; |
|
302 |
- } |
|
303 |
- |
|
304 |
- hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr, &device_priv->deviceHandle); |
|
305 |
- if (FAILED(hr)) { |
|
306 |
- av_log(NULL, loglevel, "Failed to open device handle\n"); |
|
307 |
- goto fail; |
|
308 |
- } |
|
309 |
- |
|
310 |
- hr = IDirect3DDeviceManager9_GetVideoService(device_hwctx->devmgr, device_priv->deviceHandle, &IID_IDirectXVideoDecoderService, (void **)&ctx->decoder_service); |
|
240 |
+ hr = IDirect3DDeviceManager9_GetVideoService(device_hwctx->devmgr, device_handle, |
|
241 |
+ &IID_IDirectXVideoDecoderService, |
|
242 |
+ (void **)&ctx->decoder_service); |
|
243 |
+ IDirect3DDeviceManager9_CloseDeviceHandle(device_hwctx->devmgr, device_handle); |
|
311 | 244 |
if (FAILED(hr)) { |
312 | 245 |
av_log(NULL, loglevel, "Failed to create IDirectXVideoDecoderService\n"); |
313 | 246 |
goto fail; |
314 | 247 |
} |
315 | 248 |
|
316 |
- ret = av_hwdevice_ctx_init(ctx->hw_device_ctx); |
|
317 |
- if (ret < 0) { |
|
318 |
- av_log(NULL, loglevel, "Failed to initialize the HW device context\n"); |
|
319 |
- goto fail; |
|
320 |
- } |
|
321 |
- |
|
322 | 249 |
ctx->tmp_frame = av_frame_alloc(); |
323 | 250 |
if (!ctx->tmp_frame) |
324 | 251 |
goto fail; |
... | ... |
@@ -523,102 +523,14 @@ fail: |
523 | 523 |
|
524 | 524 |
static AVClass *vaapi_log = &vaapi_class; |
525 | 525 |
|
526 |
-static av_cold void vaapi_device_uninit(AVHWDeviceContext *hwdev) |
|
527 |
-{ |
|
528 |
- AVVAAPIDeviceContext *hwctx = hwdev->hwctx; |
|
529 |
- av_log(&vaapi_log, AV_LOG_VERBOSE, "Terminating VAAPI connection.\n"); |
|
530 |
- vaTerminate(hwctx->display); |
|
531 |
-} |
|
532 |
- |
|
533 | 526 |
av_cold int vaapi_device_init(const char *device) |
534 | 527 |
{ |
535 |
- AVHWDeviceContext *hwdev; |
|
536 |
- AVVAAPIDeviceContext *hwctx; |
|
537 |
- VADisplay display; |
|
538 |
- VAStatus vas; |
|
539 |
- int major, minor, err; |
|
540 |
- |
|
541 |
- display = 0; |
|
542 |
- |
|
543 |
-#if HAVE_VAAPI_X11 |
|
544 |
- if (!display) { |
|
545 |
- Display *x11_display; |
|
546 |
- |
|
547 |
- // Try to open the device as an X11 display. |
|
548 |
- x11_display = XOpenDisplay(device); |
|
549 |
- if (!x11_display) { |
|
550 |
- av_log(&vaapi_log, AV_LOG_WARNING, "Cannot open X11 display " |
|
551 |
- "%s.\n", XDisplayName(device)); |
|
552 |
- } else { |
|
553 |
- display = vaGetDisplay(x11_display); |
|
554 |
- if (!display) { |
|
555 |
- av_log(&vaapi_log, AV_LOG_WARNING, "Cannot open a VA display " |
|
556 |
- "from X11 display %s.\n", XDisplayName(device)); |
|
557 |
- XCloseDisplay(x11_display); |
|
558 |
- } else { |
|
559 |
- av_log(&vaapi_log, AV_LOG_VERBOSE, "Opened VA display via " |
|
560 |
- "X11 display %s.\n", XDisplayName(device)); |
|
561 |
- } |
|
562 |
- } |
|
563 |
- } |
|
564 |
-#endif |
|
565 |
- |
|
566 |
-#if HAVE_VAAPI_DRM |
|
567 |
- if (!display && device) { |
|
568 |
- int drm_fd; |
|
569 |
- |
|
570 |
- // Try to open the device as a DRM path. |
|
571 |
- drm_fd = open(device, O_RDWR); |
|
572 |
- if (drm_fd < 0) { |
|
573 |
- av_log(&vaapi_log, AV_LOG_WARNING, "Cannot open DRM device %s.\n", |
|
574 |
- device); |
|
575 |
- } else { |
|
576 |
- display = vaGetDisplayDRM(drm_fd); |
|
577 |
- if (!display) { |
|
578 |
- av_log(&vaapi_log, AV_LOG_WARNING, "Cannot open a VA display " |
|
579 |
- "from DRM device %s.\n", device); |
|
580 |
- close(drm_fd); |
|
581 |
- } else { |
|
582 |
- av_log(&vaapi_log, AV_LOG_VERBOSE, "Opened VA display via " |
|
583 |
- "DRM device %s.\n", device); |
|
584 |
- } |
|
585 |
- } |
|
586 |
- } |
|
587 |
-#endif |
|
588 |
- |
|
589 |
- if (!display) { |
|
590 |
- av_log(&vaapi_log, AV_LOG_ERROR, "No VA display found for " |
|
591 |
- "device %s.\n", device); |
|
592 |
- return AVERROR(EINVAL); |
|
593 |
- } |
|
594 |
- |
|
595 |
- vas = vaInitialize(display, &major, &minor); |
|
596 |
- if (vas != VA_STATUS_SUCCESS) { |
|
597 |
- av_log(&vaapi_log, AV_LOG_ERROR, "Failed to initialise VAAPI " |
|
598 |
- "connection: %d (%s).\n", vas, vaErrorStr(vas)); |
|
599 |
- return AVERROR(EIO); |
|
600 |
- } |
|
601 |
- av_log(&vaapi_log, AV_LOG_VERBOSE, "Initialised VAAPI connection: " |
|
602 |
- "version %d.%d\n", major, minor); |
|
603 |
- |
|
604 |
- hw_device_ctx = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI); |
|
605 |
- if (!hw_device_ctx) { |
|
606 |
- av_log(&vaapi_log, AV_LOG_ERROR, "Failed to create VAAPI " |
|
607 |
- "hardware context.\n"); |
|
608 |
- vaTerminate(display); |
|
609 |
- return AVERROR(ENOMEM); |
|
610 |
- } |
|
611 |
- |
|
612 |
- hwdev = (AVHWDeviceContext*)hw_device_ctx->data; |
|
613 |
- hwdev->free = &vaapi_device_uninit; |
|
614 |
- |
|
615 |
- hwctx = hwdev->hwctx; |
|
616 |
- hwctx->display = display; |
|
528 |
+ int err; |
|
617 | 529 |
|
618 |
- err = av_hwdevice_ctx_init(hw_device_ctx); |
|
530 |
+ err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, |
|
531 |
+ device, NULL, 0); |
|
619 | 532 |
if (err < 0) { |
620 |
- av_log(&vaapi_log, AV_LOG_ERROR, "Failed to initialise VAAPI " |
|
621 |
- "hardware context: %d\n", err); |
|
533 |
+ av_log(&vaapi_log, AV_LOG_ERROR, "Failed to create a VAAPI device\n"); |
|
622 | 534 |
return err; |
623 | 535 |
} |
624 | 536 |
|
... | ... |
@@ -18,11 +18,6 @@ |
18 | 18 |
|
19 | 19 |
#include <stdint.h> |
20 | 20 |
|
21 |
-#include <vdpau/vdpau.h> |
|
22 |
-#include <vdpau/vdpau_x11.h> |
|
23 |
- |
|
24 |
-#include <X11/Xlib.h> |
|
25 |
- |
|
26 | 21 |
#include "ffmpeg.h" |
27 | 22 |
|
28 | 23 |
#include "libavcodec/vdpau.h" |
... | ... |
@@ -38,23 +33,6 @@ typedef struct VDPAUContext { |
38 | 38 |
AVFrame *tmp_frame; |
39 | 39 |
} VDPAUContext; |
40 | 40 |
|
41 |
-typedef struct VDPAUHWDevicePriv { |
|
42 |
- VdpDeviceDestroy *device_destroy; |
|
43 |
- Display *dpy; |
|
44 |
-} VDPAUHWDevicePriv; |
|
45 |
- |
|
46 |
-static void device_free(AVHWDeviceContext *ctx) |
|
47 |
-{ |
|
48 |
- AVVDPAUDeviceContext *hwctx = ctx->hwctx; |
|
49 |
- VDPAUHWDevicePriv *priv = ctx->user_opaque; |
|
50 |
- |
|
51 |
- if (priv->device_destroy) |
|
52 |
- priv->device_destroy(hwctx->device); |
|
53 |
- if (priv->dpy) |
|
54 |
- XCloseDisplay(priv->dpy); |
|
55 |
- av_freep(&priv); |
|
56 |
-} |
|
57 |
- |
|
58 | 41 |
static void vdpau_uninit(AVCodecContext *s) |
59 | 42 |
{ |
60 | 43 |
InputStream *ist = s->opaque; |
... | ... |
@@ -106,15 +84,8 @@ static int vdpau_alloc(AVCodecContext *s) |
106 | 106 |
InputStream *ist = s->opaque; |
107 | 107 |
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; |
108 | 108 |
VDPAUContext *ctx; |
109 |
- const char *display, *vendor; |
|
110 |
- VdpStatus err; |
|
111 | 109 |
int ret; |
112 | 110 |
|
113 |
- VdpDevice device; |
|
114 |
- VdpGetProcAddress *get_proc_address; |
|
115 |
- VdpGetInformationString *get_information_string; |
|
116 |
- |
|
117 |
- VDPAUHWDevicePriv *device_priv = NULL; |
|
118 | 111 |
AVBufferRef *device_ref = NULL; |
119 | 112 |
AVHWDeviceContext *device_ctx; |
120 | 113 |
AVVDPAUDeviceContext *device_hwctx; |
... | ... |
@@ -124,12 +95,6 @@ static int vdpau_alloc(AVCodecContext *s) |
124 | 124 |
if (!ctx) |
125 | 125 |
return AVERROR(ENOMEM); |
126 | 126 |
|
127 |
- device_priv = av_mallocz(sizeof(*device_priv)); |
|
128 |
- if (!device_priv) { |
|
129 |
- av_freep(&ctx); |
|
130 |
- goto fail; |
|
131 |
- } |
|
132 |
- |
|
133 | 127 |
ist->hwaccel_ctx = ctx; |
134 | 128 |
ist->hwaccel_uninit = vdpau_uninit; |
135 | 129 |
ist->hwaccel_get_buffer = vdpau_get_buffer; |
... | ... |
@@ -139,51 +104,12 @@ static int vdpau_alloc(AVCodecContext *s) |
139 | 139 |
if (!ctx->tmp_frame) |
140 | 140 |
goto fail; |
141 | 141 |
|
142 |
- device_priv->dpy = XOpenDisplay(ist->hwaccel_device); |
|
143 |
- if (!device_priv->dpy) { |
|
144 |
- av_log(NULL, loglevel, "Cannot open the X11 display %s.\n", |
|
145 |
- XDisplayName(ist->hwaccel_device)); |
|
146 |
- goto fail; |
|
147 |
- } |
|
148 |
- display = XDisplayString(device_priv->dpy); |
|
149 |
- |
|
150 |
- err = vdp_device_create_x11(device_priv->dpy, XDefaultScreen(device_priv->dpy), |
|
151 |
- &device, &get_proc_address); |
|
152 |
- if (err != VDP_STATUS_OK) { |
|
153 |
- av_log(NULL, loglevel, "VDPAU device creation on X11 display %s failed.\n", |
|
154 |
- display); |
|
155 |
- goto fail; |
|
156 |
- } |
|
157 |
- |
|
158 |
-#define GET_CALLBACK(id, result) \ |
|
159 |
-do { \ |
|
160 |
- void *tmp; \ |
|
161 |
- err = get_proc_address(device, id, &tmp); \ |
|
162 |
- if (err != VDP_STATUS_OK) { \ |
|
163 |
- av_log(NULL, loglevel, "Error getting the " #id " callback.\n"); \ |
|
164 |
- goto fail; \ |
|
165 |
- } \ |
|
166 |
- result = tmp; \ |
|
167 |
-} while (0) |
|
168 |
- |
|
169 |
- GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string); |
|
170 |
- GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, device_priv->device_destroy); |
|
171 |
- |
|
172 |
- device_ref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VDPAU); |
|
173 |
- if (!device_ref) |
|
174 |
- goto fail; |
|
175 |
- device_ctx = (AVHWDeviceContext*)device_ref->data; |
|
176 |
- device_hwctx = device_ctx->hwctx; |
|
177 |
- device_ctx->user_opaque = device_priv; |
|
178 |
- device_ctx->free = device_free; |
|
179 |
- device_hwctx->device = device; |
|
180 |
- device_hwctx->get_proc_address = get_proc_address; |
|
181 |
- |
|
182 |
- device_priv = NULL; |
|
183 |
- |
|
184 |
- ret = av_hwdevice_ctx_init(device_ref); |
|
142 |
+ ret = av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_VDPAU, |
|
143 |
+ ist->hwaccel_device, NULL, 0); |
|
185 | 144 |
if (ret < 0) |
186 | 145 |
goto fail; |
146 |
+ device_ctx = (AVHWDeviceContext*)device_ref->data; |
|
147 |
+ device_hwctx = device_ctx->hwctx; |
|
187 | 148 |
|
188 | 149 |
ctx->hw_frames_ctx = av_hwframe_ctx_alloc(device_ref); |
189 | 150 |
if (!ctx->hw_frames_ctx) |
... | ... |
@@ -200,26 +126,17 @@ do { |
200 | 200 |
if (ret < 0) |
201 | 201 |
goto fail; |
202 | 202 |
|
203 |
- if (av_vdpau_bind_context(s, device, get_proc_address, 0)) |
|
203 |
+ if (av_vdpau_bind_context(s, device_hwctx->device, device_hwctx->get_proc_address, 0)) |
|
204 | 204 |
goto fail; |
205 | 205 |
|
206 |
- get_information_string(&vendor); |
|
207 |
- av_log(NULL, AV_LOG_VERBOSE, "Using VDPAU -- %s -- on X11 display %s, " |
|
208 |
- "to decode input stream #%d:%d.\n", vendor, |
|
209 |
- display, ist->file_index, ist->st->index); |
|
206 |
+ av_log(NULL, AV_LOG_VERBOSE, "Using VDPAU to decode input stream #%d:%d.\n", |
|
207 |
+ ist->file_index, ist->st->index); |
|
210 | 208 |
|
211 | 209 |
return 0; |
212 | 210 |
|
213 | 211 |
fail: |
214 | 212 |
av_log(NULL, loglevel, "VDPAU init failed for stream #%d:%d.\n", |
215 | 213 |
ist->file_index, ist->st->index); |
216 |
- if (device_priv) { |
|
217 |
- if (device_priv->device_destroy) |
|
218 |
- device_priv->device_destroy(device); |
|
219 |
- if (device_priv->dpy) |
|
220 |
- XCloseDisplay(device_priv->dpy); |
|
221 |
- } |
|
222 |
- av_freep(&device_priv); |
|
223 | 214 |
av_buffer_unref(&device_ref); |
224 | 215 |
vdpau_uninit(s); |
225 | 216 |
return AVERROR(EINVAL); |
... | ... |
@@ -633,6 +633,7 @@ OBJS-$(CONFIG_XWD_DECODER) += xwddec.o |
633 | 633 |
OBJS-$(CONFIG_XWD_ENCODER) += xwdenc.o |
634 | 634 |
OBJS-$(CONFIG_Y41P_DECODER) += y41pdec.o |
635 | 635 |
OBJS-$(CONFIG_Y41P_ENCODER) += y41penc.o |
636 |
+OBJS-$(CONFIG_YLC_DECODER) += ylc.o |
|
636 | 637 |
OBJS-$(CONFIG_YOP_DECODER) += yop.o |
637 | 638 |
OBJS-$(CONFIG_YUV4_DECODER) += yuv4dec.o |
638 | 639 |
OBJS-$(CONFIG_YUV4_ENCODER) += yuv4enc.o |
... | ... |
@@ -370,6 +370,7 @@ void avcodec_register_all(void) |
370 | 370 |
REGISTER_DECODER(XL, xl); |
371 | 371 |
REGISTER_ENCDEC (XWD, xwd); |
372 | 372 |
REGISTER_ENCDEC (Y41P, y41p); |
373 |
+ REGISTER_DECODER(YLC, ylc); |
|
373 | 374 |
REGISTER_DECODER(YOP, yop); |
374 | 375 |
REGISTER_ENCDEC (YUV4, yuv4); |
375 | 376 |
REGISTER_DECODER(ZERO12V, zero12v); |
... | ... |
@@ -408,6 +408,7 @@ enum AVCodecID { |
408 | 408 |
AV_CODEC_ID_M101, |
409 | 409 |
AV_CODEC_ID_MAGICYUV, |
410 | 410 |
AV_CODEC_ID_SHEERVIDEO, |
411 |
+ AV_CODEC_ID_YLC, |
|
411 | 412 |
|
412 | 413 |
/* various PCM "codecs" */ |
413 | 414 |
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs |
... | ... |
@@ -3217,9 +3218,9 @@ typedef struct AVCodecContext { |
3217 | 3217 |
#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14 |
3218 | 3218 |
#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15 |
3219 | 3219 |
|
3220 |
-#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 0 |
|
3221 |
-#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 1 |
|
3222 |
-#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 2 |
|
3220 |
+#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1 |
|
3221 |
+#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2 |
|
3222 |
+#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768 |
|
3223 | 3223 |
#define FF_PROFILE_JPEG2000_DCINEMA_2K 3 |
3224 | 3224 |
#define FF_PROFILE_JPEG2000_DCINEMA_4K 4 |
3225 | 3225 |
|
... | ... |
@@ -4117,7 +4118,6 @@ void avcodec_register_all(void); |
4117 | 4117 |
* important mainly for encoders, e.g. libx264). |
4118 | 4118 |
* |
4119 | 4119 |
* @return An AVCodecContext filled with default values or NULL on failure. |
4120 |
- * @see avcodec_get_context_defaults |
|
4121 | 4120 |
*/ |
4122 | 4121 |
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); |
4123 | 4122 |
|
... | ... |
@@ -4127,16 +4127,14 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); |
4127 | 4127 |
*/ |
4128 | 4128 |
void avcodec_free_context(AVCodecContext **avctx); |
4129 | 4129 |
|
4130 |
+#if FF_API_GET_CONTEXT_DEFAULTS |
|
4130 | 4131 |
/** |
4131 |
- * Set the fields of the given AVCodecContext to default values corresponding |
|
4132 |
- * to the given codec (defaults may be codec-dependent). |
|
4133 |
- * |
|
4134 |
- * Do not call this function if a non-NULL codec has been passed |
|
4135 |
- * to avcodec_alloc_context3() that allocated this AVCodecContext. |
|
4136 |
- * If codec is non-NULL, it is illegal to call avcodec_open2() with a |
|
4137 |
- * different codec on this AVCodecContext. |
|
4132 |
+ * @deprecated This function should not be used, as closing and opening a codec |
|
4133 |
+ * context multiple time is not supported. A new codec context should be |
|
4134 |
+ * allocated for each new use. |
|
4138 | 4135 |
*/ |
4139 | 4136 |
int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); |
4137 |
+#endif |
|
4140 | 4138 |
|
4141 | 4139 |
/** |
4142 | 4140 |
* Get the AVClass for AVCodecContext. It can be used in combination with |
... | ... |
@@ -4146,6 +4144,7 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); |
4146 | 4146 |
*/ |
4147 | 4147 |
const AVClass *avcodec_get_class(void); |
4148 | 4148 |
|
4149 |
+#if FF_API_COPY_CONTEXT |
|
4149 | 4150 |
/** |
4150 | 4151 |
* Get the AVClass for AVFrame. It can be used in combination with |
4151 | 4152 |
* AV_OPT_SEARCH_FAKE_OBJ for examining options. |
... | ... |
@@ -4172,8 +4171,16 @@ const AVClass *avcodec_get_subtitle_rect_class(void); |
4172 | 4172 |
* avcodec_alloc_context3(NULL), but otherwise uninitialized |
4173 | 4173 |
* @param src source codec context |
4174 | 4174 |
* @return AVERROR() on error (e.g. memory allocation error), 0 on success |
4175 |
+ * |
|
4176 |
+ * @deprecated The semantics of this function are ill-defined and it should not |
|
4177 |
+ * be used. If you need to transfer the stream parameters from one codec context |
|
4178 |
+ * to another, use an intermediate AVCodecParameters instance and the |
|
4179 |
+ * avcodec_parameters_from_context() / avcodec_parameters_to_context() |
|
4180 |
+ * functions. |
|
4175 | 4181 |
*/ |
4182 |
+attribute_deprecated |
|
4176 | 4183 |
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); |
4184 |
+#endif |
|
4177 | 4185 |
|
4178 | 4186 |
/** |
4179 | 4187 |
* Allocate a new AVCodecParameters and set its fields to default values |
... | ... |
@@ -4246,9 +4253,8 @@ int avcodec_parameters_to_context(AVCodecContext *codec, |
4246 | 4246 |
* @param avctx The context to initialize. |
4247 | 4247 |
* @param codec The codec to open this context for. If a non-NULL codec has been |
4248 | 4248 |
* previously passed to avcodec_alloc_context3() or |
4249 |
- * avcodec_get_context_defaults3() for this context, then this |
|
4250 |
- * parameter MUST be either NULL or equal to the previously passed |
|
4251 |
- * codec. |
|
4249 |
+ * for this context, then this parameter MUST be either NULL or |
|
4250 |
+ * equal to the previously passed codec. |
|
4252 | 4251 |
* @param options A dictionary filled with AVCodecContext and codec-private options. |
4253 | 4252 |
* On return this object will be filled with options that were not found. |
4254 | 4253 |
* |
... | ... |
@@ -4263,9 +4269,13 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **op |
4263 | 4263 |
* (but not the AVCodecContext itself). |
4264 | 4264 |
* |
4265 | 4265 |
* Calling this function on an AVCodecContext that hasn't been opened will free |
4266 |
- * the codec-specific data allocated in avcodec_alloc_context3() / |
|
4267 |
- * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will |
|
4268 |
- * do nothing. |
|
4266 |
+ * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL |
|
4267 |
+ * codec. Subsequent calls will do nothing. |
|
4268 |
+ * |
|
4269 |
+ * @note Do not use this function. Use avcodec_free_context() to destroy a |
|
4270 |
+ * codec context (either open or closed). Opening and closing a codec context |
|
4271 |
+ * multiple times is not supported anymore -- use multiple codec contexts |
|
4272 |
+ * instead. |
|
4269 | 4273 |
*/ |
4270 | 4274 |
int avcodec_close(AVCodecContext *avctx); |
4271 | 4275 |
|
... | ... |
@@ -1556,6 +1556,13 @@ static const AVCodecDescriptor codec_descriptors[] = { |
1556 | 1556 |
.long_name = NULL_IF_CONFIG_SMALL("BitJazz SheerVideo"), |
1557 | 1557 |
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, |
1558 | 1558 |
}, |
1559 |
+ { |
|
1560 |
+ .id = AV_CODEC_ID_YLC, |
|
1561 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
1562 |
+ .name = "ylc", |
|
1563 |
+ .long_name = NULL_IF_CONFIG_SMALL("YUY2 Lossless Codec"), |
|
1564 |
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, |
|
1565 |
+ }, |
|
1559 | 1566 |
|
1560 | 1567 |
/* various PCM "codecs" */ |
1561 | 1568 |
{ |
... | ... |
@@ -151,8 +151,8 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb, |
151 | 151 |
/* [DIRAC_STD] 10.3.2 Frame size. frame_size(video_params) */ |
152 | 152 |
/* [DIRAC_STD] custom_dimensions_flag */ |
153 | 153 |
if (get_bits1(gb)) { |
154 |
- dsh->width = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_WIDTH */ |
|
155 |
- dsh->height = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_HEIGHT */ |
|
154 |
+ dsh->width = get_interleaved_ue_golomb(gb); /* [DIRAC_STD] FRAME_WIDTH */ |
|
155 |
+ dsh->height = get_interleaved_ue_golomb(gb); /* [DIRAC_STD] FRAME_HEIGHT */ |
|
156 | 156 |
} |
157 | 157 |
|
158 | 158 |
/* [DIRAC_STD] 10.3.3 Chroma Sampling Format. |
... | ... |
@@ -160,7 +160,7 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb, |
160 | 160 |
/* [DIRAC_STD] custom_chroma_format_flag */ |
161 | 161 |
if (get_bits1(gb)) |
162 | 162 |
/* [DIRAC_STD] CHROMA_FORMAT_INDEX */ |
163 |
- dsh->chroma_format = svq3_get_ue_golomb(gb); |
|
163 |
+ dsh->chroma_format = get_interleaved_ue_golomb(gb); |
|
164 | 164 |
if (dsh->chroma_format > 2U) { |
165 | 165 |
if (log_ctx) |
166 | 166 |
av_log(log_ctx, AV_LOG_ERROR, "Unknown chroma format %d\n", |
... | ... |
@@ -172,22 +172,22 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb, |
172 | 172 |
/* [DIRAC_STD] custom_scan_format_flag */ |
173 | 173 |
if (get_bits1(gb)) |
174 | 174 |
/* [DIRAC_STD] SOURCE_SAMPLING */ |
175 |
- dsh->interlaced = svq3_get_ue_golomb(gb); |
|
175 |
+ dsh->interlaced = get_interleaved_ue_golomb(gb); |
|
176 | 176 |
if (dsh->interlaced > 1U) |
177 | 177 |
return AVERROR_INVALIDDATA; |
178 | 178 |
|
179 | 179 |
/* [DIRAC_STD] 10.3.5 Frame Rate. frame_rate(video_params) */ |
180 | 180 |
if (get_bits1(gb)) { /* [DIRAC_STD] custom_frame_rate_flag */ |
181 |
- dsh->frame_rate_index = svq3_get_ue_golomb(gb); |
|
181 |
+ dsh->frame_rate_index = get_interleaved_ue_golomb(gb); |
|
182 | 182 |
|
183 | 183 |
if (dsh->frame_rate_index > 10U) |
184 | 184 |
return AVERROR_INVALIDDATA; |
185 | 185 |
|
186 | 186 |
if (!dsh->frame_rate_index) { |
187 | 187 |
/* [DIRAC_STD] FRAME_RATE_NUMER */ |
188 |
- frame_rate.num = svq3_get_ue_golomb(gb); |
|
188 |
+ frame_rate.num = get_interleaved_ue_golomb(gb); |
|
189 | 189 |
/* [DIRAC_STD] FRAME_RATE_DENOM */ |
190 |
- frame_rate.den = svq3_get_ue_golomb(gb); |
|
190 |
+ frame_rate.den = get_interleaved_ue_golomb(gb); |
|
191 | 191 |
} |
192 | 192 |
} |
193 | 193 |
/* [DIRAC_STD] preset_frame_rate(video_params, index) */ |
... | ... |
@@ -204,14 +204,14 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb, |
204 | 204 |
* pixel_aspect_ratio(video_params) */ |
205 | 205 |
if (get_bits1(gb)) { /* [DIRAC_STD] custom_pixel_aspect_ratio_flag */ |
206 | 206 |
/* [DIRAC_STD] index */ |
207 |
- dsh->aspect_ratio_index = svq3_get_ue_golomb(gb); |
|
207 |
+ dsh->aspect_ratio_index = get_interleaved_ue_golomb(gb); |
|
208 | 208 |
|
209 | 209 |
if (dsh->aspect_ratio_index > 6U) |
210 | 210 |
return AVERROR_INVALIDDATA; |
211 | 211 |
|
212 | 212 |
if (!dsh->aspect_ratio_index) { |
213 |
- dsh->sample_aspect_ratio.num = svq3_get_ue_golomb(gb); |
|
214 |
- dsh->sample_aspect_ratio.den = svq3_get_ue_golomb(gb); |
|
213 |
+ dsh->sample_aspect_ratio.num = get_interleaved_ue_golomb(gb); |
|
214 |
+ dsh->sample_aspect_ratio.den = get_interleaved_ue_golomb(gb); |
|
215 | 215 |
} |
216 | 216 |
} |
217 | 217 |
/* [DIRAC_STD] Take value from Table 10.4 Available preset pixel |
... | ... |
@@ -223,13 +223,13 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb, |
223 | 223 |
/* [DIRAC_STD] 10.3.7 Clean area. clean_area(video_params) */ |
224 | 224 |
if (get_bits1(gb)) { /* [DIRAC_STD] custom_clean_area_flag */ |
225 | 225 |
/* [DIRAC_STD] CLEAN_WIDTH */ |
226 |
- dsh->clean_width = svq3_get_ue_golomb(gb); |
|
226 |
+ dsh->clean_width = get_interleaved_ue_golomb(gb); |
|
227 | 227 |
/* [DIRAC_STD] CLEAN_HEIGHT */ |
228 |
- dsh->clean_height = svq3_get_ue_golomb(gb); |
|
228 |
+ dsh->clean_height = get_interleaved_ue_golomb(gb); |
|
229 | 229 |
/* [DIRAC_STD] CLEAN_LEFT_OFFSET */ |
230 |
- dsh->clean_left_offset = svq3_get_ue_golomb(gb); |
|
230 |
+ dsh->clean_left_offset = get_interleaved_ue_golomb(gb); |
|
231 | 231 |
/* [DIRAC_STD] CLEAN_RIGHT_OFFSET */ |
232 |
- dsh->clean_right_offset = svq3_get_ue_golomb(gb); |
|
232 |
+ dsh->clean_right_offset = get_interleaved_ue_golomb(gb); |
|
233 | 233 |
} |
234 | 234 |
|
235 | 235 |
/* [DIRAC_STD] 10.3.8 Signal range. signal_range(video_params) |
... | ... |
@@ -237,17 +237,17 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb, |
237 | 237 |
* AVCOL_RANGE_MPEG/JPEG values */ |
238 | 238 |
if (get_bits1(gb)) { /* [DIRAC_STD] custom_signal_range_flag */ |
239 | 239 |
/* [DIRAC_STD] index */ |
240 |
- dsh->pixel_range_index = svq3_get_ue_golomb(gb); |
|
240 |
+ dsh->pixel_range_index = get_interleaved_ue_golomb(gb); |
|
241 | 241 |
|
242 | 242 |
if (dsh->pixel_range_index > 4U) |
243 | 243 |
return AVERROR_INVALIDDATA; |
244 | 244 |
|
245 | 245 |
/* This assumes either fullrange or MPEG levels only */ |
246 | 246 |
if (!dsh->pixel_range_index) { |
247 |
- luma_offset = svq3_get_ue_golomb(gb); |
|
248 |
- luma_depth = av_log2(svq3_get_ue_golomb(gb)) + 1; |
|
249 |
- svq3_get_ue_golomb(gb); /* chroma offset */ |
|
250 |
- svq3_get_ue_golomb(gb); /* chroma excursion */ |
|
247 |
+ luma_offset = get_interleaved_ue_golomb(gb); |
|
248 |
+ luma_depth = av_log2(get_interleaved_ue_golomb(gb)) + 1; |
|
249 |
+ get_interleaved_ue_golomb(gb); /* chroma offset */ |
|
250 |
+ get_interleaved_ue_golomb(gb); /* chroma excursion */ |
|
251 | 251 |
dsh->color_range = luma_offset ? AVCOL_RANGE_MPEG |
252 | 252 |
: AVCOL_RANGE_JPEG; |
253 | 253 |
} |
... | ... |
@@ -279,7 +279,7 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb, |
279 | 279 |
/* [DIRAC_STD] 10.3.9 Colour specification. colour_spec(video_params) */ |
280 | 280 |
if (get_bits1(gb)) { /* [DIRAC_STD] custom_colour_spec_flag */ |
281 | 281 |
/* [DIRAC_STD] index */ |
282 |
- idx = dsh->color_spec_index = svq3_get_ue_golomb(gb); |
|
282 |
+ idx = dsh->color_spec_index = get_interleaved_ue_golomb(gb); |
|
283 | 283 |
|
284 | 284 |
if (dsh->color_spec_index > 4U) |
285 | 285 |
return AVERROR_INVALIDDATA; |
... | ... |
@@ -291,20 +291,20 @@ static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb, |
291 | 291 |
if (!dsh->color_spec_index) { |
292 | 292 |
/* [DIRAC_STD] 10.3.9.1 Colour primaries */ |
293 | 293 |
if (get_bits1(gb)) { |
294 |
- idx = svq3_get_ue_golomb(gb); |
|
294 |
+ idx = get_interleaved_ue_golomb(gb); |
|
295 | 295 |
if (idx < 3U) |
296 | 296 |
dsh->color_primaries = dirac_primaries[idx]; |
297 | 297 |
} |
298 | 298 |
/* [DIRAC_STD] 10.3.9.2 Colour matrix */ |
299 | 299 |
if (get_bits1(gb)) { |
300 |
- idx = svq3_get_ue_golomb(gb); |
|
300 |
+ idx = get_interleaved_ue_golomb(gb); |
|
301 | 301 |
if (!idx) |
302 | 302 |
dsh->colorspace = AVCOL_SPC_BT709; |
303 | 303 |
else if (idx == 1) |
304 | 304 |
dsh->colorspace = AVCOL_SPC_BT470BG; |
305 | 305 |
} |
306 | 306 |
/* [DIRAC_STD] 10.3.9.3 Transfer function */ |
307 |
- if (get_bits1(gb) && !svq3_get_ue_golomb(gb)) |
|
307 |
+ if (get_bits1(gb) && !get_interleaved_ue_golomb(gb)) |
|
308 | 308 |
dsh->color_trc = AVCOL_TRC_BT709; |
309 | 309 |
} |
310 | 310 |
} else { |
... | ... |
@@ -336,13 +336,13 @@ int av_dirac_parse_sequence_header(AVDiracSeqHeader **pdsh, |
336 | 336 |
goto fail; |
337 | 337 |
|
338 | 338 |
/* [DIRAC_SPEC] 10.1 Parse Parameters. parse_parameters() */ |
339 |
- dsh->version.major = svq3_get_ue_golomb(&gb); |
|
340 |
- dsh->version.minor = svq3_get_ue_golomb(&gb); |
|
341 |
- dsh->profile = svq3_get_ue_golomb(&gb); |
|
342 |
- dsh->level = svq3_get_ue_golomb(&gb); |
|
339 |
+ dsh->version.major = get_interleaved_ue_golomb(&gb); |
|
340 |
+ dsh->version.minor = get_interleaved_ue_golomb(&gb); |
|
341 |
+ dsh->profile = get_interleaved_ue_golomb(&gb); |
|
342 |
+ dsh->level = get_interleaved_ue_golomb(&gb); |
|
343 | 343 |
/* [DIRAC_SPEC] sequence_header() -> base_video_format as defined in |
344 | 344 |
* 10.2 Base Video Format, table 10.1 Dirac predefined video formats */ |
345 |
- video_format = svq3_get_ue_golomb(&gb); |
|
345 |
+ video_format = get_interleaved_ue_golomb(&gb); |
|
346 | 346 |
|
347 | 347 |
if (dsh->version.major < 2 && log_ctx) |
348 | 348 |
av_log(log_ctx, AV_LOG_WARNING, "Stream is old and may not work\n"); |
... | ... |
@@ -377,7 +377,7 @@ int av_dirac_parse_sequence_header(AVDiracSeqHeader **pdsh, |
377 | 377 |
|
378 | 378 |
/* [DIRAC_STD] picture_coding_mode shall be 0 for fields and 1 for frames |
379 | 379 |
* currently only used to signal field coding */ |
380 |
- picture_coding_mode = svq3_get_ue_golomb(&gb); |
|
380 |
+ picture_coding_mode = get_interleaved_ue_golomb(&gb); |
|
381 | 381 |
if (picture_coding_mode != 0) { |
382 | 382 |
if (log_ctx) { |
383 | 383 |
av_log(log_ctx, AV_LOG_ERROR, "Unsupported picture coding mode %d", |
... | ... |
@@ -671,9 +671,9 @@ static void decode_component(DiracContext *s, int comp) |
671 | 671 |
|
672 | 672 |
align_get_bits(&s->gb); |
673 | 673 |
/* [DIRAC_STD] 13.4.2 subband() */ |
674 |
- b->length = svq3_get_ue_golomb(&s->gb); |
|
674 |
+ b->length = get_interleaved_ue_golomb(&s->gb); |
|
675 | 675 |
if (b->length) { |
676 |
- b->quant = svq3_get_ue_golomb(&s->gb); |
|
676 |
+ b->quant = get_interleaved_ue_golomb(&s->gb); |
|
677 | 677 |
align_get_bits(&s->gb); |
678 | 678 |
b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8; |
679 | 679 |
b->length = FFMIN(b->length, FFMAX(get_bits_left(&s->gb)/8, 0)); |
... | ... |
@@ -1001,7 +1001,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s) |
1001 | 1001 |
align_get_bits(gb); |
1002 | 1002 |
/* [DIRAC_STD] 11.2.2 Block parameters. block_parameters() */ |
1003 | 1003 |
/* Luma and Chroma are equal. 11.2.3 */ |
1004 |
- idx = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */ |
|
1004 |
+ idx = get_interleaved_ue_golomb(gb); /* [DIRAC_STD] index */ |
|
1005 | 1005 |
|
1006 | 1006 |
if (idx > 4) { |
1007 | 1007 |
av_log(s->avctx, AV_LOG_ERROR, "Block prediction index too high\n"); |
... | ... |
@@ -1009,10 +1009,10 @@ static int dirac_unpack_prediction_parameters(DiracContext *s) |
1009 | 1009 |
} |
1010 | 1010 |
|
1011 | 1011 |
if (idx == 0) { |
1012 |
- s->plane[0].xblen = svq3_get_ue_golomb(gb); |
|
1013 |
- s->plane[0].yblen = svq3_get_ue_golomb(gb); |
|
1014 |
- s->plane[0].xbsep = svq3_get_ue_golomb(gb); |
|
1015 |
- s->plane[0].ybsep = svq3_get_ue_golomb(gb); |
|
1012 |
+ s->plane[0].xblen = get_interleaved_ue_golomb(gb); |
|
1013 |
+ s->plane[0].yblen = get_interleaved_ue_golomb(gb); |
|
1014 |
+ s->plane[0].xbsep = get_interleaved_ue_golomb(gb); |
|
1015 |
+ s->plane[0].ybsep = get_interleaved_ue_golomb(gb); |
|
1016 | 1016 |
} else { |
1017 | 1017 |
/*[DIRAC_STD] preset_block_params(index). Table 11.1 */ |
1018 | 1018 |
s->plane[0].xblen = default_blen[idx-1]; |
... | ... |
@@ -1046,7 +1046,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s) |
1046 | 1046 |
|
1047 | 1047 |
/*[DIRAC_STD] 11.2.5 Motion vector precision. motion_vector_precision() |
1048 | 1048 |
Read motion vector precision */ |
1049 |
- s->mv_precision = svq3_get_ue_golomb(gb); |
|
1049 |
+ s->mv_precision = get_interleaved_ue_golomb(gb); |
|
1050 | 1050 |
if (s->mv_precision > 3) { |
1051 | 1051 |
av_log(s->avctx, AV_LOG_ERROR, "MV precision finer than eighth-pel\n"); |
1052 | 1052 |
return AVERROR_INVALIDDATA; |
... | ... |
@@ -1066,7 +1066,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s) |
1066 | 1066 |
/* [DIRAC_STD] zoom_rotate_shear(gparams) |
1067 | 1067 |
zoom/rotation/shear parameters */ |
1068 | 1068 |
if (get_bits1(gb)) { |
1069 |
- s->globalmc[ref].zrs_exp = svq3_get_ue_golomb(gb); |
|
1069 |
+ s->globalmc[ref].zrs_exp = get_interleaved_ue_golomb(gb); |
|
1070 | 1070 |
s->globalmc[ref].zrs[0][0] = dirac_get_se_golomb(gb); |
1071 | 1071 |
s->globalmc[ref].zrs[0][1] = dirac_get_se_golomb(gb); |
1072 | 1072 |
s->globalmc[ref].zrs[1][0] = dirac_get_se_golomb(gb); |
... | ... |
@@ -1077,7 +1077,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s) |
1077 | 1077 |
} |
1078 | 1078 |
/* [DIRAC_STD] perspective(gparams) */ |
1079 | 1079 |
if (get_bits1(gb)) { |
1080 |
- s->globalmc[ref].perspective_exp = svq3_get_ue_golomb(gb); |
|
1080 |
+ s->globalmc[ref].perspective_exp = get_interleaved_ue_golomb(gb); |
|
1081 | 1081 |
s->globalmc[ref].perspective[0] = dirac_get_se_golomb(gb); |
1082 | 1082 |
s->globalmc[ref].perspective[1] = dirac_get_se_golomb(gb); |
1083 | 1083 |
} |
... | ... |
@@ -1086,7 +1086,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s) |
1086 | 1086 |
|
1087 | 1087 |
/*[DIRAC_STD] 11.2.7 Picture prediction mode. prediction_mode() |
1088 | 1088 |
Picture prediction mode, not currently used. */ |
1089 |
- if (svq3_get_ue_golomb(gb)) { |
|
1089 |
+ if (get_interleaved_ue_golomb(gb)) { |
|
1090 | 1090 |
av_log(s->avctx, AV_LOG_ERROR, "Unknown picture prediction mode\n"); |
1091 | 1091 |
return AVERROR_INVALIDDATA; |
1092 | 1092 |
} |
... | ... |
@@ -1098,7 +1098,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s) |
1098 | 1098 |
s->weight[1] = 1; |
1099 | 1099 |
|
1100 | 1100 |
if (get_bits1(gb)) { |
1101 |
- s->weight_log2denom = svq3_get_ue_golomb(gb); |
|
1101 |
+ s->weight_log2denom = get_interleaved_ue_golomb(gb); |
|
1102 | 1102 |
s->weight[0] = dirac_get_se_golomb(gb); |
1103 | 1103 |
if (s->num_refs == 2) |
1104 | 1104 |
s->weight[1] = dirac_get_se_golomb(gb); |
... | ... |
@@ -1117,7 +1117,7 @@ static int dirac_unpack_idwt_params(DiracContext *s) |
1117 | 1117 |
unsigned tmp; |
1118 | 1118 |
|
1119 | 1119 |
#define CHECKEDREAD(dst, cond, errmsg) \ |
1120 |
- tmp = svq3_get_ue_golomb(gb); \ |
|
1120 |
+ tmp = get_interleaved_ue_golomb(gb); \ |
|
1121 | 1121 |
if (cond) { \ |
1122 | 1122 |
av_log(s->avctx, AV_LOG_ERROR, errmsg); \ |
1123 | 1123 |
return AVERROR_INVALIDDATA; \ |
... | ... |
@@ -1151,18 +1151,18 @@ static int dirac_unpack_idwt_params(DiracContext *s) |
1151 | 1151 |
} |
1152 | 1152 |
} |
1153 | 1153 |
else { |
1154 |
- s->num_x = svq3_get_ue_golomb(gb); |
|
1155 |
- s->num_y = svq3_get_ue_golomb(gb); |
|
1154 |
+ s->num_x = get_interleaved_ue_golomb(gb); |
|
1155 |
+ s->num_y = get_interleaved_ue_golomb(gb); |
|
1156 | 1156 |
if (s->ld_picture) { |
1157 |
- s->lowdelay.bytes.num = svq3_get_ue_golomb(gb); |
|
1158 |
- s->lowdelay.bytes.den = svq3_get_ue_golomb(gb); |
|
1157 |
+ s->lowdelay.bytes.num = get_interleaved_ue_golomb(gb); |
|
1158 |
+ s->lowdelay.bytes.den = get_interleaved_ue_golomb(gb); |
|
1159 | 1159 |
if (s->lowdelay.bytes.den <= 0) { |
1160 | 1160 |
av_log(s->avctx,AV_LOG_ERROR,"Invalid lowdelay.bytes.den\n"); |
1161 | 1161 |
return AVERROR_INVALIDDATA; |
1162 | 1162 |
} |
1163 | 1163 |
} else if (s->hq_picture) { |
1164 |
- s->highquality.prefix_bytes = svq3_get_ue_golomb(gb); |
|
1165 |
- s->highquality.size_scaler = svq3_get_ue_golomb(gb); |
|
1164 |
+ s->highquality.prefix_bytes = get_interleaved_ue_golomb(gb); |
|
1165 |
+ s->highquality.size_scaler = get_interleaved_ue_golomb(gb); |
|
1166 | 1166 |
if (s->highquality.prefix_bytes >= INT_MAX / 8) { |
1167 | 1167 |
av_log(s->avctx,AV_LOG_ERROR,"too many prefix bytes\n"); |
1168 | 1168 |
return AVERROR_INVALIDDATA; |
... | ... |
@@ -1173,11 +1173,11 @@ static int dirac_unpack_idwt_params(DiracContext *s) |
1173 | 1173 |
if (get_bits1(gb)) { |
1174 | 1174 |
av_log(s->avctx,AV_LOG_DEBUG,"Low Delay: Has Custom Quantization Matrix!\n"); |
1175 | 1175 |
/* custom quantization matrix */ |
1176 |
- s->lowdelay.quant[0][0] = svq3_get_ue_golomb(gb); |
|
1176 |
+ s->lowdelay.quant[0][0] = get_interleaved_ue_golomb(gb); |
|
1177 | 1177 |
for (level = 0; level < s->wavelet_depth; level++) { |
1178 |
- s->lowdelay.quant[level][1] = svq3_get_ue_golomb(gb); |
|
1179 |
- s->lowdelay.quant[level][2] = svq3_get_ue_golomb(gb); |
|
1180 |
- s->lowdelay.quant[level][3] = svq3_get_ue_golomb(gb); |
|
1178 |
+ s->lowdelay.quant[level][1] = get_interleaved_ue_golomb(gb); |
|
1179 |
+ s->lowdelay.quant[level][2] = get_interleaved_ue_golomb(gb); |
|
1180 |
+ s->lowdelay.quant[level][3] = get_interleaved_ue_golomb(gb); |
|
1181 | 1181 |
} |
1182 | 1182 |
} else { |
1183 | 1183 |
if (s->wavelet_depth > 4) { |
... | ... |
@@ -1388,7 +1388,7 @@ static int dirac_unpack_block_motion_data(DiracContext *s) |
1388 | 1388 |
|
1389 | 1389 |
/* [DIRAC_STD] 12.3.1 Superblock splitting modes. superblock_split_modes() |
1390 | 1390 |
decode superblock split modes */ |
1391 |
- ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb)); /* svq3_get_ue_golomb(gb) is the length */ |
|
1391 |
+ ff_dirac_init_arith_decoder(arith, gb, get_interleaved_ue_golomb(gb)); /* get_interleaved_ue_golomb(gb) is the length */ |
|
1392 | 1392 |
for (y = 0; y < s->sbheight; y++) { |
1393 | 1393 |
for (x = 0; x < s->sbwidth; x++) { |
1394 | 1394 |
unsigned int split = dirac_get_arith_uint(arith, CTX_SB_F1, CTX_SB_DATA); |
... | ... |
@@ -1400,13 +1400,13 @@ static int dirac_unpack_block_motion_data(DiracContext *s) |
1400 | 1400 |
} |
1401 | 1401 |
|
1402 | 1402 |
/* setup arith decoding */ |
1403 |
- ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb)); |
|
1403 |
+ ff_dirac_init_arith_decoder(arith, gb, get_interleaved_ue_golomb(gb)); |
|
1404 | 1404 |
for (i = 0; i < s->num_refs; i++) { |
1405 |
- ff_dirac_init_arith_decoder(arith + 4 + 2 * i, gb, svq3_get_ue_golomb(gb)); |
|
1406 |
- ff_dirac_init_arith_decoder(arith + 5 + 2 * i, gb, svq3_get_ue_golomb(gb)); |
|
1405 |
+ ff_dirac_init_arith_decoder(arith + 4 + 2 * i, gb, get_interleaved_ue_golomb(gb)); |
|
1406 |
+ ff_dirac_init_arith_decoder(arith + 5 + 2 * i, gb, get_interleaved_ue_golomb(gb)); |
|
1407 | 1407 |
} |
1408 | 1408 |
for (i = 0; i < 3; i++) |
1409 |
- ff_dirac_init_arith_decoder(arith+1+i, gb, svq3_get_ue_golomb(gb)); |
|
1409 |
+ ff_dirac_init_arith_decoder(arith+1+i, gb, get_interleaved_ue_golomb(gb)); |
|
1410 | 1410 |
|
1411 | 1411 |
for (y = 0; y < s->sbheight; y++) |
1412 | 1412 |
for (x = 0; x < s->sbwidth; x++) { |
... | ... |
@@ -487,7 +487,7 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) |
487 | 487 |
SKIP_BITS(name, gb, n); \ |
488 | 488 |
} while (0) |
489 | 489 |
|
490 |
-#define GET_RL_VLC_INTERNAL(level, run, name, gb, table, bits, \ |
|
490 |
+#define GET_RL_VLC(level, run, name, gb, table, bits, \ |
|
491 | 491 |
max_depth, need_update) \ |
492 | 492 |
do { \ |
493 | 493 |
int n, nb_bits; \ |
... | ... |
@@ -584,89 +584,4 @@ static inline int skip_1stop_8data_bits(GetBitContext *gb) |
584 | 584 |
return 0; |
585 | 585 |
} |
586 | 586 |
|
587 |
-//#define TRACE |
|
588 |
- |
|
589 |
-#ifdef TRACE |
|
590 |
-static inline void print_bin(int bits, int n) |
|
591 |
-{ |
|
592 |
- int i; |
|
593 |
- |
|
594 |
- for (i = n - 1; i >= 0; i--) |
|
595 |
- av_log(NULL, AV_LOG_DEBUG, "%d", (bits >> i) & 1); |
|
596 |
- for (i = n; i < 24; i++) |
|
597 |
- av_log(NULL, AV_LOG_DEBUG, " "); |
|
598 |
-} |
|
599 |
- |
|
600 |
-static inline int get_bits_trace(GetBitContext *s, int n, const char *file, |
|
601 |
- const char *func, int line) |
|
602 |
-{ |
|
603 |
- int r = get_bits(s, n); |
|
604 |
- |
|
605 |
- print_bin(r, n); |
|
606 |
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", |
|
607 |
- r, n, r, get_bits_count(s) - n, file, func, line); |
|
608 |
- |
|
609 |
- return r; |
|
610 |
-} |
|
611 |
- |
|
612 |
-static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], |
|
613 |
- int bits, int max_depth, const char *file, |
|
614 |
- const char *func, int line) |
|
615 |
-{ |
|
616 |
- int show = show_bits(s, 24); |
|
617 |
- int pos = get_bits_count(s); |
|
618 |
- int r = get_vlc2(s, table, bits, max_depth); |
|
619 |
- int len = get_bits_count(s) - pos; |
|
620 |
- int bits2 = show >> (24 - len); |
|
621 |
- |
|
622 |
- print_bin(bits2, len); |
|
623 |
- |
|
624 |
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", |
|
625 |
- bits2, len, r, pos, file, func, line); |
|
626 |
- |
|
627 |
- return r; |
|
628 |
-} |
|
629 |
- |
|
630 |
-#define GET_RL_VLC(level, run, name, gb, table, bits, \ |
|
631 |
- max_depth, need_update) \ |
|
632 |
- do { \ |
|
633 |
- int show = SHOW_UBITS(name, gb, 24); \ |
|
634 |
- int len; \ |
|
635 |
- int pos = name ## _index; \ |
|
636 |
- \ |
|
637 |
- GET_RL_VLC_INTERNAL(level, run, name, gb, table, bits,max_depth, need_update); \ |
|
638 |
- \ |
|
639 |
- len = name ## _index - pos + 1; \ |
|
640 |
- show = show >> (24 - len); \ |
|
641 |
- \ |
|
642 |
- print_bin(show, len); \ |
|
643 |
- \ |
|
644 |
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d/%-3d rlv @%5d in %s %s:%d\n",\ |
|
645 |
- show, len, run-1, level, pos, __FILE__, __PRETTY_FUNCTION__, __LINE__);\ |
|
646 |
- } while (0) \ |
|
647 |
- |
|
648 |
- |
|
649 |
-static inline int get_xbits_trace(GetBitContext *s, int n, const char *file, |
|
650 |
- const char *func, int line) |
|
651 |
-{ |
|
652 |
- int show = show_bits(s, n); |
|
653 |
- int r = get_xbits(s, n); |
|
654 |
- |
|
655 |
- print_bin(show, n); |
|
656 |
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", |
|
657 |
- show, n, r, get_bits_count(s) - n, file, func, line); |
|
658 |
- |
|
659 |
- return r; |
|
660 |
-} |
|
661 |
- |
|
662 |
-#define get_bits(s, n) get_bits_trace(s , n, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
|
663 |
-#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
|
664 |
-#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
|
665 |
- |
|
666 |
-#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
|
667 |
-#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) |
|
668 |
-#else //TRACE |
|
669 |
-#define GET_RL_VLC GET_RL_VLC_INTERNAL |
|
670 |
-#endif |
|
671 |
- |
|
672 | 587 |
#endif /* AVCODEC_GET_BITS_H */ |
... | ... |
@@ -112,7 +112,7 @@ static inline int get_ue_golomb_31(GetBitContext *gb) |
112 | 112 |
return ff_ue_golomb_vlc_code[buf]; |
113 | 113 |
} |
114 | 114 |
|
115 |
-static inline unsigned svq3_get_ue_golomb(GetBitContext *gb) |
|
115 |
+static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb) |
|
116 | 116 |
{ |
117 | 117 |
uint32_t buf; |
118 | 118 |
|
... | ... |
@@ -219,7 +219,7 @@ static inline int get_se_golomb_long(GetBitContext *gb) |
219 | 219 |
return ((buf >> 1) ^ sign) + 1; |
220 | 220 |
} |
221 | 221 |
|
222 |
-static inline int svq3_get_se_golomb(GetBitContext *gb) |
|
222 |
+static inline int get_interleaved_se_golomb(GetBitContext *gb) |
|
223 | 223 |
{ |
224 | 224 |
unsigned int buf; |
225 | 225 |
|
... | ... |
@@ -254,7 +254,7 @@ static inline int svq3_get_se_golomb(GetBitContext *gb) |
254 | 254 |
|
255 | 255 |
static inline int dirac_get_se_golomb(GetBitContext *gb) |
256 | 256 |
{ |
257 |
- uint32_t ret = svq3_get_ue_golomb(gb); |
|
257 |
+ uint32_t ret = get_interleaved_ue_golomb(gb); |
|
258 | 258 |
|
259 | 259 |
if (ret) { |
260 | 260 |
int sign = -get_bits1(gb); |
... | ... |
@@ -409,8 +409,6 @@ static inline int get_ue(GetBitContext *s, const char *file, const char *func, |
409 | 409 |
int len = get_bits_count(s) - pos; |
410 | 410 |
int bits = show >> (24 - len); |
411 | 411 |
|
412 |
- print_bin(bits, len); |
|
413 |
- |
|
414 | 412 |
av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d ue @%5d in %s %s:%d\n", |
415 | 413 |
bits, len, i, pos, file, func, line); |
416 | 414 |
|
... | ... |
@@ -426,8 +424,6 @@ static inline int get_se(GetBitContext *s, const char *file, const char *func, |
426 | 426 |
int len = get_bits_count(s) - pos; |
427 | 427 |
int bits = show >> (24 - len); |
428 | 428 |
|
429 |
- print_bin(bits, len); |
|
430 |
- |
|
431 | 429 |
av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d se @%5d in %s %s:%d\n", |
432 | 430 |
bits, len, i, pos, file, func, line); |
433 | 431 |
|
... | ... |
@@ -443,8 +439,6 @@ static inline int get_te(GetBitContext *s, int r, char *file, const char *func, |
443 | 443 |
int len = get_bits_count(s) - pos; |
444 | 444 |
int bits = show >> (24 - len); |
445 | 445 |
|
446 |
- print_bin(bits, len); |
|
447 |
- |
|
448 | 446 |
av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d te @%5d in %s %s:%d\n", |
449 | 447 |
bits, len, i, pos, file, func, line); |
450 | 448 |
|
... | ... |
@@ -422,10 +422,6 @@ static inline int get_level_prefix(GetBitContext *gb){ |
422 | 422 |
buf=GET_CACHE(re, gb); |
423 | 423 |
|
424 | 424 |
log= 32 - av_log2(buf); |
425 |
-#ifdef TRACE |
|
426 |
- print_bin(buf>>(32-log), log); |
|
427 |
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d lpr @%5d in %s get_level_prefix\n", buf>>(32-log), log, log-1, get_bits_count(gb), __FILE__); |
|
428 |
-#endif |
|
429 | 425 |
|
430 | 426 |
LAST_SKIP_BITS(re, gb, log); |
431 | 427 |
CLOSE_READER(re, gb); |
... | ... |
@@ -352,6 +352,12 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx) |
352 | 352 |
ctx->enc_params.cp_cinema = ctx->cinema_mode; |
353 | 353 |
#endif |
354 | 354 |
|
355 |
+ if (!ctx->numresolution) { |
|
356 |
+ ctx->numresolution = 6; |
|
357 |
+ while (FFMIN(avctx->width, avctx->height) >> ctx->numresolution < 1) |
|
358 |
+ ctx->numresolution --; |
|
359 |
+ } |
|
360 |
+ |
|
355 | 361 |
ctx->enc_params.mode = !!avctx->global_quality; |
356 | 362 |
ctx->enc_params.prog_order = ctx->prog_order; |
357 | 363 |
ctx->enc_params.numresolution = ctx->numresolution; |
... | ... |
@@ -815,7 +821,7 @@ static const AVOption options[] = { |
815 | 815 |
{ "rpcl", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ(RPCL) }, 0, 0, VE, "prog_order" }, |
816 | 816 |
{ "pcrl", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ(PCRL) }, 0, 0, VE, "prog_order" }, |
817 | 817 |
{ "cprl", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ(CPRL) }, 0, 0, VE, "prog_order" }, |
818 |
- { "numresolution", NULL, OFFSET(numresolution), AV_OPT_TYPE_INT, { .i64 = 6 }, 1, INT_MAX, VE }, |
|
818 |
+ { "numresolution", NULL, OFFSET(numresolution), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, |
|
819 | 819 |
{ "numlayers", NULL, OFFSET(numlayers), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 10, VE }, |
820 | 820 |
{ "disto_alloc", NULL, OFFSET(disto_alloc), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE }, |
821 | 821 |
{ "fixed_alloc", NULL, OFFSET(fixed_alloc), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, |
... | ... |
@@ -71,6 +71,7 @@ typedef struct MPADecodeContext { |
71 | 71 |
MPA_DECODE_HEADER |
72 | 72 |
uint8_t last_buf[LAST_BUF_SIZE]; |
73 | 73 |
int last_buf_size; |
74 |
+ int extrasize; |
|
74 | 75 |
/* next header (used in free format parsing) */ |
75 | 76 |
uint32_t free_format_next_header; |
76 | 77 |
GetBitContext gb; |
... | ... |
@@ -819,9 +820,10 @@ static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g, |
819 | 819 |
static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, |
820 | 820 |
int *end_pos2) |
821 | 821 |
{ |
822 |
- if (s->in_gb.buffer && *pos >= s->gb.size_in_bits) { |
|
822 |
+ if (s->in_gb.buffer && *pos >= s->gb.size_in_bits - s->extrasize * 8) { |
|
823 | 823 |
s->gb = s->in_gb; |
824 | 824 |
s->in_gb.buffer = NULL; |
825 |
+ s->extrasize = 0; |
|
825 | 826 |
av_assert2((get_bits_count(&s->gb) & 7) == 0); |
826 | 827 |
skip_bits_long(&s->gb, *pos - *end_pos); |
827 | 828 |
*end_pos2 = |
... | ... |
@@ -853,7 +855,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g, |
853 | 853 |
int i; |
854 | 854 |
int last_pos, bits_left; |
855 | 855 |
VLC *vlc; |
856 |
- int end_pos = FFMIN(end_pos2, s->gb.size_in_bits); |
|
856 |
+ int end_pos = FFMIN(end_pos2, s->gb.size_in_bits - s->extrasize * 8); |
|
857 | 857 |
|
858 | 858 |
/* low frequencies (called big values) */ |
859 | 859 |
s_index = 0; |
... | ... |
@@ -1387,18 +1389,16 @@ static int mp_decode_layer3(MPADecodeContext *s) |
1387 | 1387 |
if (!s->adu_mode) { |
1388 | 1388 |
int skip; |
1389 | 1389 |
const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); |
1390 |
- int extrasize = av_clip(get_bits_left(&s->gb) >> 3, 0, EXTRABYTES); |
|
1390 |
+ s->extrasize = av_clip((get_bits_left(&s->gb) >> 3) - s->extrasize, 0, |
|
1391 |
+ FFMAX(0, LAST_BUF_SIZE - s->last_buf_size)); |
|
1391 | 1392 |
av_assert1((get_bits_count(&s->gb) & 7) == 0); |
1392 | 1393 |
/* now we get bits from the main_data_begin offset */ |
1393 | 1394 |
ff_dlog(s->avctx, "seekback:%d, lastbuf:%d\n", |
1394 | 1395 |
main_data_begin, s->last_buf_size); |
1395 | 1396 |
|
1396 |
- memcpy(s->last_buf + s->last_buf_size, ptr, extrasize); |
|
1397 |
+ memcpy(s->last_buf + s->last_buf_size, ptr, s->extrasize); |
|
1397 | 1398 |
s->in_gb = s->gb; |
1398 |
- init_get_bits(&s->gb, s->last_buf, s->last_buf_size*8); |
|
1399 |
-#if !UNCHECKED_BITSTREAM_READER |
|
1400 |
- s->gb.size_in_bits_plus8 += FFMAX(extrasize, LAST_BUF_SIZE - s->last_buf_size) * 8; |
|
1401 |
-#endif |
|
1399 |
+ init_get_bits(&s->gb, s->last_buf, (s->last_buf_size + s->extrasize) * 8); |
|
1402 | 1400 |
s->last_buf_size <<= 3; |
1403 | 1401 |
for (gr = 0; gr < nb_granules && (s->last_buf_size >> 3) < main_data_begin; gr++) { |
1404 | 1402 |
for (ch = 0; ch < s->nb_channels; ch++) { |
... | ... |
@@ -1409,15 +1409,17 @@ static int mp_decode_layer3(MPADecodeContext *s) |
1409 | 1409 |
} |
1410 | 1410 |
} |
1411 | 1411 |
skip = s->last_buf_size - 8 * main_data_begin; |
1412 |
- if (skip >= s->gb.size_in_bits && s->in_gb.buffer) { |
|
1413 |
- skip_bits_long(&s->in_gb, skip - s->gb.size_in_bits); |
|
1412 |
+ if (skip >= s->gb.size_in_bits - s->extrasize * 8 && s->in_gb.buffer) { |
|
1413 |
+ skip_bits_long(&s->in_gb, skip - s->gb.size_in_bits + s->extrasize * 8); |
|
1414 | 1414 |
s->gb = s->in_gb; |
1415 | 1415 |
s->in_gb.buffer = NULL; |
1416 |
+ s->extrasize = 0; |
|
1416 | 1417 |
} else { |
1417 | 1418 |
skip_bits_long(&s->gb, skip); |
1418 | 1419 |
} |
1419 | 1420 |
} else { |
1420 | 1421 |
gr = 0; |
1422 |
+ s->extrasize = 0; |
|
1421 | 1423 |
} |
1422 | 1424 |
|
1423 | 1425 |
for (; gr < nb_granules; gr++) { |
... | ... |
@@ -1582,7 +1584,7 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples, |
1582 | 1582 |
s->last_buf_size=0; |
1583 | 1583 |
if (s->in_gb.buffer) { |
1584 | 1584 |
align_get_bits(&s->gb); |
1585 |
- i = get_bits_left(&s->gb)>>3; |
|
1585 |
+ i = (get_bits_left(&s->gb) >> 3) - s->extrasize; |
|
1586 | 1586 |
if (i >= 0 && i <= BACKSTEP_SIZE) { |
1587 | 1587 |
memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i); |
1588 | 1588 |
s->last_buf_size=i; |
... | ... |
@@ -1590,12 +1592,12 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples, |
1590 | 1590 |
av_log(s->avctx, AV_LOG_ERROR, "invalid old backstep %d\n", i); |
1591 | 1591 |
s->gb = s->in_gb; |
1592 | 1592 |
s->in_gb.buffer = NULL; |
1593 |
+ s->extrasize = 0; |
|
1593 | 1594 |
} |
1594 | 1595 |
|
1595 | 1596 |
align_get_bits(&s->gb); |
1596 | 1597 |
av_assert1((get_bits_count(&s->gb) & 7) == 0); |
1597 |
- i = get_bits_left(&s->gb) >> 3; |
|
1598 |
- |
|
1598 |
+ i = (get_bits_left(&s->gb) >> 3) - s->extrasize; |
|
1599 | 1599 |
if (i < 0 || i > BACKSTEP_SIZE || nb_frames < 0) { |
1600 | 1600 |
if (i < 0) |
1601 | 1601 |
av_log(s->avctx, AV_LOG_ERROR, "invalid new backstep %d\n", i); |
... | ... |
@@ -89,7 +89,7 @@ static const AVClass av_codec_context_class = { |
89 | 89 |
.get_category = get_category, |
90 | 90 |
}; |
91 | 91 |
|
92 |
-int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) |
|
92 |
+static int init_context_defaults(AVCodecContext *s, const AVCodec *codec) |
|
93 | 93 |
{ |
94 | 94 |
int flags=0; |
95 | 95 |
memset(s, 0, sizeof(AVCodecContext)); |
... | ... |
@@ -146,6 +146,13 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) |
146 | 146 |
return 0; |
147 | 147 |
} |
148 | 148 |
|
149 |
+#if FF_API_GET_CONTEXT_DEFAULTS |
|
150 |
+int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) |
|
151 |
+{ |
|
152 |
+ return init_context_defaults(s, codec); |
|
153 |
+} |
|
154 |
+#endif |
|
155 |
+ |
|
149 | 156 |
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec) |
150 | 157 |
{ |
151 | 158 |
AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); |
... | ... |
@@ -153,7 +160,7 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec) |
153 | 153 |
if (!avctx) |
154 | 154 |
return NULL; |
155 | 155 |
|
156 |
- if(avcodec_get_context_defaults3(avctx, codec) < 0){ |
|
156 |
+ if (init_context_defaults(avctx, codec) < 0) { |
|
157 | 157 |
av_free(avctx); |
158 | 158 |
return NULL; |
159 | 159 |
} |
... | ... |
@@ -179,6 +186,7 @@ void avcodec_free_context(AVCodecContext **pavctx) |
179 | 179 |
av_freep(pavctx); |
180 | 180 |
} |
181 | 181 |
|
182 |
+#if FF_API_COPY_CONTEXT |
|
182 | 183 |
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) |
183 | 184 |
{ |
184 | 185 |
const AVCodec *orig_codec = dest->codec; |
... | ... |
@@ -225,6 +233,7 @@ FF_ENABLE_DEPRECATION_WARNINGS |
225 | 225 |
dest->inter_matrix = NULL; |
226 | 226 |
dest->rc_override = NULL; |
227 | 227 |
dest->subtitle_header = NULL; |
228 |
+ dest->hw_frames_ctx = NULL; |
|
228 | 229 |
|
229 | 230 |
#define alloc_and_copy_or_fail(obj, size, pad) \ |
230 | 231 |
if (src->obj && size > 0) { \ |
... | ... |
@@ -245,19 +254,27 @@ FF_ENABLE_DEPRECATION_WARNINGS |
245 | 245 |
av_assert0(dest->subtitle_header_size == src->subtitle_header_size); |
246 | 246 |
#undef alloc_and_copy_or_fail |
247 | 247 |
|
248 |
+ if (src->hw_frames_ctx) { |
|
249 |
+ dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx); |
|
250 |
+ if (!dest->hw_frames_ctx) |
|
251 |
+ goto fail; |
|
252 |
+ } |
|
253 |
+ |
|
248 | 254 |
return 0; |
249 | 255 |
|
250 | 256 |
fail: |
257 |
+ av_freep(&dest->subtitle_header); |
|
251 | 258 |
av_freep(&dest->rc_override); |
252 | 259 |
av_freep(&dest->intra_matrix); |
253 | 260 |
av_freep(&dest->inter_matrix); |
254 | 261 |
av_freep(&dest->extradata); |
255 |
- av_freep(&dest->subtitle_header); |
|
262 |
+ av_buffer_unref(&dest->hw_frames_ctx); |
|
256 | 263 |
dest->subtitle_header_size = 0; |
257 | 264 |
dest->extradata_size = 0; |
258 | 265 |
av_opt_free(dest); |
259 | 266 |
return AVERROR(ENOMEM); |
260 | 267 |
} |
268 |
+#endif |
|
261 | 269 |
|
262 | 270 |
const AVClass *avcodec_get_class(void) |
263 | 271 |
{ |
... | ... |
@@ -89,7 +89,7 @@ static int rv30_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t |
89 | 89 |
|
90 | 90 |
for(i = 0; i < 4; i++, dst += r->intra_types_stride - 4){ |
91 | 91 |
for(j = 0; j < 4; j+= 2){ |
92 |
- unsigned code = svq3_get_ue_golomb(gb) << 1; |
|
92 |
+ unsigned code = get_interleaved_ue_golomb(gb) << 1; |
|
93 | 93 |
if (code > 80U*2U) { |
94 | 94 |
av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction code\n"); |
95 | 95 |
return -1; |
... | ... |
@@ -117,7 +117,7 @@ static int rv30_decode_mb_info(RV34DecContext *r) |
117 | 117 |
static const int rv30_b_types[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 }; |
118 | 118 |
MpegEncContext *s = &r->s; |
119 | 119 |
GetBitContext *gb = &s->gb; |
120 |
- unsigned code = svq3_get_ue_golomb(gb); |
|
120 |
+ unsigned code = get_interleaved_ue_golomb(gb); |
|
121 | 121 |
|
122 | 122 |
if (code > 11) { |
123 | 123 |
av_log(s->avctx, AV_LOG_ERROR, "Incorrect MB type code\n"); |
... | ... |
@@ -864,8 +864,8 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type) |
864 | 864 |
|
865 | 865 |
memset(r->dmv, 0, sizeof(r->dmv)); |
866 | 866 |
for(i = 0; i < num_mvs[block_type]; i++){ |
867 |
- r->dmv[i][0] = svq3_get_se_golomb(gb); |
|
868 |
- r->dmv[i][1] = svq3_get_se_golomb(gb); |
|
867 |
+ r->dmv[i][0] = get_interleaved_se_golomb(gb); |
|
868 |
+ r->dmv[i][1] = get_interleaved_se_golomb(gb); |
|
869 | 869 |
} |
870 | 870 |
switch(block_type){ |
871 | 871 |
case RV34_MB_TYPE_INTRA: |
... | ... |
@@ -231,7 +231,7 @@ static int rv40_decode_mb_info(RV34DecContext *r) |
231 | 231 |
int mb_pos = s->mb_x + s->mb_y * s->mb_stride; |
232 | 232 |
|
233 | 233 |
if(!r->s.mb_skip_run) { |
234 |
- r->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1; |
|
234 |
+ r->s.mb_skip_run = get_interleaved_ue_golomb(gb) + 1; |
|
235 | 235 |
if(r->s.mb_skip_run > (unsigned)s->mb_num) |
236 | 236 |
return -1; |
237 | 237 |
} |
... | ... |
@@ -295,7 +295,7 @@ static inline int svq3_decode_block(GetBitContext *gb, int16_t *block, |
295 | 295 |
const uint8_t *const scan = scan_patterns[type]; |
296 | 296 |
|
297 | 297 |
for (limit = (16 >> intra); index < 16; index = limit, limit += 8) { |
298 |
- for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) { |
|
298 |
+ for (; (vlc = get_interleaved_ue_golomb(gb)) != 0; index++) { |
|
299 | 299 |
if ((int32_t)vlc < 0) |
300 | 300 |
return -1; |
301 | 301 |
|
... | ... |
@@ -534,8 +534,8 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode, |
534 | 534 |
if (mode == PREDICT_MODE) { |
535 | 535 |
dx = dy = 0; |
536 | 536 |
} else { |
537 |
- dy = svq3_get_se_golomb(&s->gb_slice); |
|
538 |
- dx = svq3_get_se_golomb(&s->gb_slice); |
|
537 |
+ dy = get_interleaved_se_golomb(&s->gb_slice); |
|
538 |
+ dx = get_interleaved_se_golomb(&s->gb_slice); |
|
539 | 539 |
|
540 | 540 |
if (dx == INVALID_VLC || dy == INVALID_VLC) { |
541 | 541 |
av_log(s->avctx, AV_LOG_ERROR, "invalid MV vlc\n"); |
... | ... |
@@ -846,7 +846,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) |
846 | 846 |
|
847 | 847 |
/* decode prediction codes for luma blocks */ |
848 | 848 |
for (i = 0; i < 16; i += 2) { |
849 |
- vlc = svq3_get_ue_golomb(&s->gb_slice); |
|
849 |
+ vlc = get_interleaved_ue_golomb(&s->gb_slice); |
|
850 | 850 |
|
851 | 851 |
if (vlc >= 25U) { |
852 | 852 |
av_log(s->avctx, AV_LOG_ERROR, |
... | ... |
@@ -924,7 +924,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) |
924 | 924 |
|
925 | 925 |
if (!IS_INTRA16x16(mb_type) && |
926 | 926 |
(!IS_SKIP(mb_type) || s->pict_type == AV_PICTURE_TYPE_B)) { |
927 |
- if ((vlc = svq3_get_ue_golomb(&s->gb_slice)) >= 48U){ |
|
927 |
+ if ((vlc = get_interleaved_ue_golomb(&s->gb_slice)) >= 48U){ |
|
928 | 928 |
av_log(s->avctx, AV_LOG_ERROR, "cbp_vlc=%"PRIu32"\n", vlc); |
929 | 929 |
return -1; |
930 | 930 |
} |
... | ... |
@@ -934,7 +934,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type) |
934 | 934 |
} |
935 | 935 |
if (IS_INTRA16x16(mb_type) || |
936 | 936 |
(s->pict_type != AV_PICTURE_TYPE_I && s->adaptive_quant && cbp)) { |
937 |
- s->qscale += svq3_get_se_golomb(&s->gb_slice); |
|
937 |
+ s->qscale += get_interleaved_se_golomb(&s->gb_slice); |
|
938 | 938 |
|
939 | 939 |
if (s->qscale > 31u) { |
940 | 940 |
av_log(s->avctx, AV_LOG_ERROR, "qscale:%d\n", s->qscale); |
... | ... |
@@ -1052,7 +1052,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx) |
1052 | 1052 |
skip_bits_long(&s->gb, slice_bytes * 8); |
1053 | 1053 |
} |
1054 | 1054 |
|
1055 |
- if ((slice_id = svq3_get_ue_golomb(&s->gb_slice)) >= 3) { |
|
1055 |
+ if ((slice_id = get_interleaved_ue_golomb(&s->gb_slice)) >= 3) { |
|
1056 | 1056 |
av_log(s->avctx, AV_LOG_ERROR, "illegal slice type %u \n", slice_id); |
1057 | 1057 |
return -1; |
1058 | 1058 |
} |
... | ... |
@@ -1245,12 +1245,12 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) |
1245 | 1245 |
avctx->has_b_frames = !s->low_delay; |
1246 | 1246 |
if (s->has_watermark) { |
1247 | 1247 |
#if CONFIG_ZLIB |
1248 |
- unsigned watermark_width = svq3_get_ue_golomb(&gb); |
|
1249 |
- unsigned watermark_height = svq3_get_ue_golomb(&gb); |
|
1250 |
- int u1 = svq3_get_ue_golomb(&gb); |
|
1248 |
+ unsigned watermark_width = get_interleaved_ue_golomb(&gb); |
|
1249 |
+ unsigned watermark_height = get_interleaved_ue_golomb(&gb); |
|
1250 |
+ int u1 = get_interleaved_ue_golomb(&gb); |
|
1251 | 1251 |
int u2 = get_bits(&gb, 8); |
1252 | 1252 |
int u3 = get_bits(&gb, 2); |
1253 |
- int u4 = svq3_get_ue_golomb(&gb); |
|
1253 |
+ int u4 = get_interleaved_ue_golomb(&gb); |
|
1254 | 1254 |
unsigned long buf_len = watermark_width * |
1255 | 1255 |
watermark_height * 4; |
1256 | 1256 |
int offset = get_bits_count(&gb) + 7 >> 3; |
... | ... |
@@ -1542,7 +1542,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data, |
1542 | 1542 |
/* TODO: support s->mb_skip_run */ |
1543 | 1543 |
} |
1544 | 1544 |
|
1545 |
- mb_type = svq3_get_ue_golomb(&s->gb_slice); |
|
1545 |
+ mb_type = get_interleaved_ue_golomb(&s->gb_slice); |
|
1546 | 1546 |
|
1547 | 1547 |
if (s->pict_type == AV_PICTURE_TYPE_I) |
1548 | 1548 |
mb_type += 8; |
... | ... |
@@ -20,6 +20,7 @@ |
20 | 20 |
#include <string.h> |
21 | 21 |
|
22 | 22 |
#include "libavutil/avassert.h" |
23 |
+#include "libavutil/common.h" |
|
23 | 24 |
#include "libavutil/log.h" |
24 | 25 |
#include "libavutil/pixdesc.h" |
25 | 26 |
|
... | ... |
@@ -887,6 +888,122 @@ fail: |
887 | 887 |
return err; |
888 | 888 |
} |
889 | 889 |
|
890 |
+static av_cold int vaapi_encode_check_config(AVCodecContext *avctx) |
|
891 |
+{ |
|
892 |
+ VAAPIEncodeContext *ctx = avctx->priv_data; |
|
893 |
+ VAStatus vas; |
|
894 |
+ int i, n, err; |
|
895 |
+ VAProfile *profiles = NULL; |
|
896 |
+ VAEntrypoint *entrypoints = NULL; |
|
897 |
+ VAConfigAttrib attr[] = { |
|
898 |
+ { VAConfigAttribRateControl }, |
|
899 |
+ { VAConfigAttribEncMaxRefFrames }, |
|
900 |
+ }; |
|
901 |
+ |
|
902 |
+ n = vaMaxNumProfiles(ctx->hwctx->display); |
|
903 |
+ profiles = av_malloc_array(n, sizeof(VAProfile)); |
|
904 |
+ if (!profiles) { |
|
905 |
+ err = AVERROR(ENOMEM); |
|
906 |
+ goto fail; |
|
907 |
+ } |
|
908 |
+ vas = vaQueryConfigProfiles(ctx->hwctx->display, profiles, &n); |
|
909 |
+ if (vas != VA_STATUS_SUCCESS) { |
|
910 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to query profiles: %d (%s).\n", |
|
911 |
+ vas, vaErrorStr(vas)); |
|
912 |
+ err = AVERROR(ENOSYS); |
|
913 |
+ goto fail; |
|
914 |
+ } |
|
915 |
+ for (i = 0; i < n; i++) { |
|
916 |
+ if (profiles[i] == ctx->va_profile) |
|
917 |
+ break; |
|
918 |
+ } |
|
919 |
+ if (i >= n) { |
|
920 |
+ av_log(ctx, AV_LOG_ERROR, "Encoding profile not found (%d).\n", |
|
921 |
+ ctx->va_profile); |
|
922 |
+ err = AVERROR(ENOSYS); |
|
923 |
+ goto fail; |
|
924 |
+ } |
|
925 |
+ |
|
926 |
+ n = vaMaxNumEntrypoints(ctx->hwctx->display); |
|
927 |
+ entrypoints = av_malloc_array(n, sizeof(VAEntrypoint)); |
|
928 |
+ if (!entrypoints) { |
|
929 |
+ err = AVERROR(ENOMEM); |
|
930 |
+ goto fail; |
|
931 |
+ } |
|
932 |
+ vas = vaQueryConfigEntrypoints(ctx->hwctx->display, ctx->va_profile, |
|
933 |
+ entrypoints, &n); |
|
934 |
+ if (vas != VA_STATUS_SUCCESS) { |
|
935 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to query entrypoints for " |
|
936 |
+ "profile %u: %d (%s).\n", ctx->va_profile, |
|
937 |
+ vas, vaErrorStr(vas)); |
|
938 |
+ err = AVERROR(ENOSYS); |
|
939 |
+ goto fail; |
|
940 |
+ } |
|
941 |
+ for (i = 0; i < n; i++) { |
|
942 |
+ if (entrypoints[i] == ctx->va_entrypoint) |
|
943 |
+ break; |
|
944 |
+ } |
|
945 |
+ if (i >= n) { |
|
946 |
+ av_log(ctx, AV_LOG_ERROR, "Encoding entrypoint not found " |
|
947 |
+ "(%d / %d).\n", ctx->va_profile, ctx->va_entrypoint); |
|
948 |
+ err = AVERROR(ENOSYS); |
|
949 |
+ goto fail; |
|
950 |
+ } |
|
951 |
+ |
|
952 |
+ vas = vaGetConfigAttributes(ctx->hwctx->display, |
|
953 |
+ ctx->va_profile, ctx->va_entrypoint, |
|
954 |
+ attr, FF_ARRAY_ELEMS(attr)); |
|
955 |
+ if (vas != VA_STATUS_SUCCESS) { |
|
956 |
+ av_log(avctx, AV_LOG_ERROR, "Failed to fetch config " |
|
957 |
+ "attributes: %d (%s).\n", vas, vaErrorStr(vas)); |
|
958 |
+ return AVERROR(EINVAL); |
|
959 |
+ } |
|
960 |
+ |
|
961 |
+ for (i = 0; i < FF_ARRAY_ELEMS(attr); i++) { |
|
962 |
+ if (attr[i].value == VA_ATTRIB_NOT_SUPPORTED) { |
|
963 |
+ // Unfortunately we have to treat this as "don't know" and hope |
|
964 |
+ // for the best, because the Intel MJPEG encoder returns this |
|
965 |
+ // for all the interesting attributes. |
|
966 |
+ continue; |
|
967 |
+ } |
|
968 |
+ switch (attr[i].type) { |
|
969 |
+ case VAConfigAttribRateControl: |
|
970 |
+ if (!(ctx->va_rc_mode & attr[i].value)) { |
|
971 |
+ av_log(avctx, AV_LOG_ERROR, "Rate control mode is not " |
|
972 |
+ "supported: %x\n", attr[i].value); |
|
973 |
+ err = AVERROR(EINVAL); |
|
974 |
+ goto fail; |
|
975 |
+ } |
|
976 |
+ break; |
|
977 |
+ case VAConfigAttribEncMaxRefFrames: |
|
978 |
+ { |
|
979 |
+ unsigned int ref_l0 = attr[i].value & 0xffff; |
|
980 |
+ unsigned int ref_l1 = (attr[i].value >> 16) & 0xffff; |
|
981 |
+ |
|
982 |
+ if (avctx->gop_size > 1 && ref_l0 < 1) { |
|
983 |
+ av_log(avctx, AV_LOG_ERROR, "P frames are not " |
|
984 |
+ "supported (%x).\n", attr[i].value); |
|
985 |
+ err = AVERROR(EINVAL); |
|
986 |
+ goto fail; |
|
987 |
+ } |
|
988 |
+ if (avctx->max_b_frames > 0 && ref_l1 < 1) { |
|
989 |
+ av_log(avctx, AV_LOG_ERROR, "B frames are not " |
|
990 |
+ "supported (%x).\n", attr[i].value); |
|
991 |
+ err = AVERROR(EINVAL); |
|
992 |
+ goto fail; |
|
993 |
+ } |
|
994 |
+ } |
|
995 |
+ break; |
|
996 |
+ } |
|
997 |
+ } |
|
998 |
+ |
|
999 |
+ err = 0; |
|
1000 |
+fail: |
|
1001 |
+ av_freep(&profiles); |
|
1002 |
+ av_freep(&entrypoints); |
|
1003 |
+ return err; |
|
1004 |
+} |
|
1005 |
+ |
|
890 | 1006 |
av_cold int ff_vaapi_encode_init(AVCodecContext *avctx, |
891 | 1007 |
const VAAPIEncodeType *type) |
892 | 1008 |
{ |
... | ... |
@@ -907,6 +1024,9 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx, |
907 | 907 |
ctx->codec = type; |
908 | 908 |
ctx->codec_options = ctx->codec_options_data; |
909 | 909 |
|
910 |
+ ctx->va_config = VA_INVALID_ID; |
|
911 |
+ ctx->va_context = VA_INVALID_ID; |
|
912 |
+ |
|
910 | 913 |
ctx->priv_data = av_mallocz(type->priv_data_size); |
911 | 914 |
if (!ctx->priv_data) { |
912 | 915 |
err = AVERROR(ENOMEM); |
... | ... |
@@ -932,6 +1052,10 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx, |
932 | 932 |
if (err < 0) |
933 | 933 |
goto fail; |
934 | 934 |
|
935 |
+ err = vaapi_encode_check_config(avctx); |
|
936 |
+ if (err < 0) |
|
937 |
+ goto fail; |
|
938 |
+ |
|
935 | 939 |
vas = vaCreateConfig(ctx->hwctx->display, |
936 | 940 |
ctx->va_profile, ctx->va_entrypoint, |
937 | 941 |
ctx->config_attributes, ctx->nb_config_attributes, |
... | ... |
@@ -1088,11 +1212,15 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx) |
1088 | 1088 |
vaapi_encode_free(avctx, pic); |
1089 | 1089 |
} |
1090 | 1090 |
|
1091 |
- if (ctx->va_context != VA_INVALID_ID) |
|
1091 |
+ if (ctx->va_context != VA_INVALID_ID) { |
|
1092 | 1092 |
vaDestroyContext(ctx->hwctx->display, ctx->va_context); |
1093 |
+ ctx->va_context = VA_INVALID_ID; |
|
1094 |
+ } |
|
1093 | 1095 |
|
1094 |
- if (ctx->va_config != VA_INVALID_ID) |
|
1096 |
+ if (ctx->va_config != VA_INVALID_ID) { |
|
1095 | 1097 |
vaDestroyConfig(ctx->hwctx->display, ctx->va_config); |
1098 |
+ ctx->va_config = VA_INVALID_ID; |
|
1099 |
+ } |
|
1096 | 1100 |
|
1097 | 1101 |
if (ctx->codec->close) |
1098 | 1102 |
ctx->codec->close(avctx); |
... | ... |
@@ -101,8 +101,8 @@ typedef struct VAAPIEncodeH264Context { |
101 | 101 |
int fixed_qp_p; |
102 | 102 |
int fixed_qp_b; |
103 | 103 |
|
104 |
+ int next_frame_num; |
|
104 | 105 |
int64_t idr_pic_count; |
105 |
- int64_t last_idr_frame; |
|
106 | 106 |
|
107 | 107 |
// Rate control configuration. |
108 | 108 |
struct { |
... | ... |
@@ -126,6 +126,7 @@ typedef struct VAAPIEncodeH264Context { |
126 | 126 |
typedef struct VAAPIEncodeH264Options { |
127 | 127 |
int qp; |
128 | 128 |
int quality; |
129 |
+ int low_power; |
|
129 | 130 |
} VAAPIEncodeH264Options; |
130 | 131 |
|
131 | 132 |
|
... | ... |
@@ -592,12 +593,17 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, |
592 | 592 |
|
593 | 593 |
if (pic->type == PICTURE_TYPE_IDR) { |
594 | 594 |
av_assert0(pic->display_order == pic->encode_order); |
595 |
- priv->last_idr_frame = pic->display_order; |
|
595 |
+ vpic->frame_num = 0; |
|
596 |
+ priv->next_frame_num = 1; |
|
596 | 597 |
} else { |
597 |
- av_assert0(pic->display_order > priv->last_idr_frame); |
|
598 |
+ vpic->frame_num = priv->next_frame_num; |
|
599 |
+ if (pic->type != PICTURE_TYPE_B) { |
|
600 |
+ // nal_ref_idc != 0 |
|
601 |
+ ++priv->next_frame_num; |
|
602 |
+ } |
|
598 | 603 |
} |
599 | 604 |
|
600 |
- vpic->frame_num = (pic->encode_order - priv->last_idr_frame) & |
|
605 |
+ vpic->frame_num = vpic->frame_num & |
|
601 | 606 |
((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1); |
602 | 607 |
|
603 | 608 |
vpic->CurrPic.picture_id = pic->recon_surface; |
... | ... |
@@ -608,10 +614,9 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, |
608 | 608 |
|
609 | 609 |
for (i = 0; i < pic->nb_refs; i++) { |
610 | 610 |
VAAPIEncodePicture *ref = pic->refs[i]; |
611 |
- av_assert0(ref && ref->encode_order >= priv->last_idr_frame); |
|
611 |
+ av_assert0(ref && ref->encode_order < pic->encode_order); |
|
612 | 612 |
vpic->ReferenceFrames[i].picture_id = ref->recon_surface; |
613 |
- vpic->ReferenceFrames[i].frame_idx = |
|
614 |
- ref->encode_order - priv->last_idr_frame; |
|
613 |
+ vpic->ReferenceFrames[i].frame_idx = ref->encode_order; |
|
615 | 614 |
vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; |
616 | 615 |
vpic->ReferenceFrames[i].TopFieldOrderCnt = ref->display_order; |
617 | 616 |
vpic->ReferenceFrames[i].BottomFieldOrderCnt = ref->display_order; |
... | ... |
@@ -856,7 +861,17 @@ static av_cold int vaapi_encode_h264_init_internal(AVCodecContext *avctx) |
856 | 856 |
avctx->profile); |
857 | 857 |
return AVERROR(EINVAL); |
858 | 858 |
} |
859 |
- ctx->va_entrypoint = VAEntrypointEncSlice; |
|
859 |
+ if (opt->low_power) { |
|
860 |
+#if VA_CHECK_VERSION(0, 39, 1) |
|
861 |
+ ctx->va_entrypoint = VAEntrypointEncSliceLP; |
|
862 |
+#else |
|
863 |
+ av_log(avctx, AV_LOG_ERROR, "Low-power encoding is not " |
|
864 |
+ "supported with this VAAPI version.\n"); |
|
865 |
+ return AVERROR(EINVAL); |
|
866 |
+#endif |
|
867 |
+ } else { |
|
868 |
+ ctx->va_entrypoint = VAEntrypointEncSlice; |
|
869 |
+ } |
|
860 | 870 |
|
861 | 871 |
ctx->input_width = avctx->width; |
862 | 872 |
ctx->input_height = avctx->height; |
... | ... |
@@ -939,7 +954,10 @@ static const AVOption vaapi_encode_h264_options[] = { |
939 | 939 |
{ "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)", |
940 | 940 |
OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 20 }, 0, 52, FLAGS }, |
941 | 941 |
{ "quality", "Set encode quality (trades off against speed, higher is faster)", |
942 |
- OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FLAGS }, |
|
942 |
+ OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 8, FLAGS }, |
|
943 |
+ { "low_power", "Use low-power encoding mode (experimental: only supported " |
|
944 |
+ "on some platforms, does not support all features)", |
|
945 |
+ OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, |
|
943 | 946 |
{ NULL }, |
944 | 947 |
}; |
945 | 948 |
|
... | ... |
@@ -28,8 +28,8 @@ |
28 | 28 |
#include "libavutil/version.h" |
29 | 29 |
|
30 | 30 |
#define LIBAVCODEC_VERSION_MAJOR 57 |
31 |
-#define LIBAVCODEC_VERSION_MINOR 47 |
|
32 |
-#define LIBAVCODEC_VERSION_MICRO 100 |
|
31 |
+#define LIBAVCODEC_VERSION_MINOR 48 |
|
32 |
+#define LIBAVCODEC_VERSION_MICRO 101 |
|
33 | 33 |
|
34 | 34 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
35 | 35 |
LIBAVCODEC_VERSION_MINOR, \ |
... | ... |
@@ -217,6 +217,12 @@ |
217 | 217 |
#ifndef FF_API_OLD_BSF |
218 | 218 |
#define FF_API_OLD_BSF (LIBAVCODEC_VERSION_MAJOR < 59) |
219 | 219 |
#endif |
220 |
+#ifndef FF_API_COPY_CONTEXT |
|
221 |
+#define FF_API_COPY_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59) |
|
222 |
+#endif |
|
223 |
+#ifndef FF_API_GET_CONTEXT_DEFAULTS |
|
224 |
+#define FF_API_GET_CONTEXT_DEFAULTS (LIBAVCODEC_VERSION_MAJOR < 59) |
|
225 |
+#endif |
|
220 | 226 |
#ifndef FF_API_NVENC_OLD_NAME |
221 | 227 |
#define FF_API_NVENC_OLD_NAME (LIBAVCODEC_VERSION_MAJOR < 59) |
222 | 228 |
#endif |
30 | 29 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,472 @@ |
0 |
+/* |
|
1 |
+ * YUY2 Lossless Codec |
|
2 |
+ * |
|
3 |
+ * This file is part of FFmpeg. |
|
4 |
+ * |
|
5 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+#include <stdio.h> |
|
21 |
+#include <stdlib.h> |
|
22 |
+#include <string.h> |
|
23 |
+ |
|
24 |
+#include "libavutil/imgutils.h" |
|
25 |
+#include "libavutil/internal.h" |
|
26 |
+#include "libavutil/intreadwrite.h" |
|
27 |
+#include "libavutil/mem.h" |
|
28 |
+#include "avcodec.h" |
|
29 |
+#include "bswapdsp.h" |
|
30 |
+#include "get_bits.h" |
|
31 |
+#include "huffyuvdsp.h" |
|
32 |
+#include "internal.h" |
|
33 |
+#include "unary.h" |
|
34 |
+ |
|
35 |
+typedef struct YLCContext { |
|
36 |
+ VLC vlc[4]; |
|
37 |
+ uint32_t table[1024]; |
|
38 |
+ uint8_t *table_bits; |
|
39 |
+ uint8_t *bitstream_bits; |
|
40 |
+ int table_bits_size; |
|
41 |
+ int bitstream_bits_size; |
|
42 |
+ BswapDSPContext bdsp; |
|
43 |
+} YLCContext; |
|
44 |
+ |
|
45 |
+static av_cold int decode_init(AVCodecContext *avctx) |
|
46 |
+{ |
|
47 |
+ YLCContext *s = avctx->priv_data; |
|
48 |
+ |
|
49 |
+ avctx->pix_fmt = AV_PIX_FMT_YUYV422; |
|
50 |
+ ff_bswapdsp_init(&s->bdsp); |
|
51 |
+ |
|
52 |
+ return 0; |
|
53 |
+} |
|
54 |
+ |
|
55 |
+typedef struct Node { |
|
56 |
+ int16_t sym; |
|
57 |
+ int16_t n0; |
|
58 |
+ uint32_t count; |
|
59 |
+ int16_t l, r; |
|
60 |
+} Node; |
|
61 |
+ |
|
62 |
+static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat, |
|
63 |
+ Node *nodes, int node, |
|
64 |
+ uint32_t pfx, int pl, int *pos) |
|
65 |
+{ |
|
66 |
+ int s; |
|
67 |
+ |
|
68 |
+ s = nodes[node].sym; |
|
69 |
+ if (s != -1) { |
|
70 |
+ bits[*pos] = (~pfx) & ((1 << FFMAX(pl, 1)) - 1); |
|
71 |
+ lens[*pos] = FFMAX(pl, 1); |
|
72 |
+ xlat[*pos] = s + (pl == 0); |
|
73 |
+ (*pos)++; |
|
74 |
+ } else { |
|
75 |
+ pfx <<= 1; |
|
76 |
+ pl++; |
|
77 |
+ get_tree_codes(bits, lens, xlat, nodes, nodes[node].l, pfx, pl, |
|
78 |
+ pos); |
|
79 |
+ pfx |= 1; |
|
80 |
+ get_tree_codes(bits, lens, xlat, nodes, nodes[node].r, pfx, pl, |
|
81 |
+ pos); |
|
82 |
+ } |
|
83 |
+} |
|
84 |
+ |
|
85 |
+static int build_vlc(AVCodecContext *avctx, VLC *vlc, const uint32_t *table) |
|
86 |
+{ |
|
87 |
+ Node nodes[512]; |
|
88 |
+ uint32_t bits[256]; |
|
89 |
+ int16_t lens[256]; |
|
90 |
+ uint8_t xlat[256]; |
|
91 |
+ int cur_node, i, j, pos = 0; |
|
92 |
+ |
|
93 |
+ ff_free_vlc(vlc); |
|
94 |
+ |
|
95 |
+ for (i = 0; i < 256; i++) { |
|
96 |
+ nodes[i].count = table[i]; |
|
97 |
+ nodes[i].sym = i; |
|
98 |
+ nodes[i].n0 = -2; |
|
99 |
+ nodes[i].l = i; |
|
100 |
+ nodes[i].r = i; |
|
101 |
+ } |
|
102 |
+ |
|
103 |
+ cur_node = 256; |
|
104 |
+ j = 0; |
|
105 |
+ do { |
|
106 |
+ for (i = 0; ; i++) { |
|
107 |
+ int new_node = j; |
|
108 |
+ int first_node = cur_node; |
|
109 |
+ int second_node = cur_node; |
|
110 |
+ int nd, st; |
|
111 |
+ |
|
112 |
+ nodes[cur_node].count = -1; |
|
113 |
+ |
|
114 |
+ do { |
|
115 |
+ int val = nodes[new_node].count; |
|
116 |
+ if (val && (val < nodes[first_node].count)) { |
|
117 |
+ if (val >= nodes[second_node].count) { |
|
118 |
+ first_node = new_node; |
|
119 |
+ } else { |
|
120 |
+ first_node = second_node; |
|
121 |
+ second_node = new_node; |
|
122 |
+ } |
|
123 |
+ } |
|
124 |
+ new_node += 1; |
|
125 |
+ } while (new_node != cur_node); |
|
126 |
+ |
|
127 |
+ if (first_node == cur_node) |
|
128 |
+ break; |
|
129 |
+ |
|
130 |
+ nd = nodes[second_node].count; |
|
131 |
+ st = nodes[first_node].count; |
|
132 |
+ nodes[second_node].count = 0; |
|
133 |
+ nodes[first_node].count = 0; |
|
134 |
+ nodes[cur_node].count = nd + st; |
|
135 |
+ nodes[cur_node].sym = -1; |
|
136 |
+ nodes[cur_node].n0 = cur_node; |
|
137 |
+ nodes[cur_node].l = first_node; |
|
138 |
+ nodes[cur_node].r = second_node; |
|
139 |
+ cur_node++; |
|
140 |
+ } |
|
141 |
+ j++; |
|
142 |
+ } while (cur_node - 256 == j); |
|
143 |
+ |
|
144 |
+ get_tree_codes(bits, lens, xlat, nodes, cur_node - 1, 0, 0, &pos); |
|
145 |
+ |
|
146 |
+ return ff_init_vlc_sparse(vlc, 10, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0); |
|
147 |
+} |
|
148 |
+ |
|
149 |
+static const uint8_t table_y1[] = { |
|
150 |
+ 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, |
|
151 |
+ 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, |
|
152 |
+ 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, |
|
153 |
+ 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, |
|
154 |
+ 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, |
|
155 |
+ 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, |
|
156 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
157 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
158 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
159 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
160 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
161 |
+ 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
162 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
163 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
164 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
165 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
166 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, |
|
167 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
168 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
169 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
170 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
171 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
172 |
+ 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, |
|
173 |
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
|
174 |
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
|
175 |
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
|
176 |
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
|
177 |
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, |
|
178 |
+ 0x02, 0x00, |
|
179 |
+}; |
|
180 |
+ |
|
181 |
+static const uint8_t table_u[] = { |
|
182 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
183 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, |
|
184 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
185 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, |
|
186 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
187 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0xFF, |
|
188 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
189 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, |
|
190 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
191 |
+ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
192 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
193 |
+ 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
194 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
195 |
+ 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
196 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
197 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
198 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, |
|
199 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
200 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, |
|
201 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
202 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, |
|
203 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
204 |
+ 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, |
|
205 |
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
|
206 |
+ 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
207 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
|
208 |
+ 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
209 |
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
|
210 |
+ 0x01, 0x00, |
|
211 |
+}; |
|
212 |
+ |
|
213 |
+static const uint8_t table_y2[] = { |
|
214 |
+ 0xFC, 0xFC, 0xFC, 0xFD, 0xFD, 0xFD, 0xFE, 0xFE, |
|
215 |
+ 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFC, |
|
216 |
+ 0xFC, 0xFC, 0xFD, 0xFD, 0xFD, 0xFE, 0xFE, 0xFE, |
|
217 |
+ 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFC, 0xFC, |
|
218 |
+ 0xFC, 0xFD, 0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, |
|
219 |
+ 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFD, 0xFD, 0xFD, |
|
220 |
+ 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, |
|
221 |
+ 0x00, 0x01, 0x01, 0x01, 0xFD, 0xFD, 0xFD, 0xFE, |
|
222 |
+ 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, |
|
223 |
+ 0x01, 0x01, 0x01, 0xFD, 0xFD, 0xFD, 0xFE, 0xFE, |
|
224 |
+ 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, |
|
225 |
+ 0x01, 0x01, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, |
|
226 |
+ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, |
|
227 |
+ 0x02, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, |
|
228 |
+ 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, |
|
229 |
+ 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00, |
|
230 |
+ 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0xFF, |
|
231 |
+ 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, |
|
232 |
+ 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0xFF, 0xFF, |
|
233 |
+ 0xFF, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, |
|
234 |
+ 0x02, 0x02, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0xFF, |
|
235 |
+ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, |
|
236 |
+ 0x02, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x01, |
|
237 |
+ 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, |
|
238 |
+ 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, |
|
239 |
+ 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, |
|
240 |
+ 0x04, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, |
|
241 |
+ 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, |
|
242 |
+ 0x04, 0x00, |
|
243 |
+}; |
|
244 |
+ |
|
245 |
+static const uint8_t table_v[] = { |
|
246 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
247 |
+ 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, |
|
248 |
+ 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, |
|
249 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
250 |
+ 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, |
|
251 |
+ 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, |
|
252 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
253 |
+ 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, |
|
254 |
+ 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, |
|
255 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
256 |
+ 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, |
|
257 |
+ 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, |
|
258 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
259 |
+ 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, |
|
260 |
+ 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, |
|
261 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
262 |
+ 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, |
|
263 |
+ 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, |
|
264 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
265 |
+ 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, |
|
266 |
+ 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, |
|
267 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
268 |
+ 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, |
|
269 |
+ 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, |
|
270 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
271 |
+ 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, |
|
272 |
+ 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, |
|
273 |
+ 0xFF, 0x00, 0x01, 0xFF, 0x00, 0x01, 0xFF, 0x00, |
|
274 |
+ 0x01, 0x00, |
|
275 |
+}; |
|
276 |
+ |
|
277 |
+static int decode_frame(AVCodecContext *avctx, |
|
278 |
+ void *data, int *got_frame, |
|
279 |
+ AVPacket *avpkt) |
|
280 |
+{ |
|
281 |
+ int TL[4] = { 128, 128, 128, 128 }; |
|
282 |
+ int L[4] = { 128, 128, 128, 128 }; |
|
283 |
+ YLCContext *s = avctx->priv_data; |
|
284 |
+ const uint8_t *buf = avpkt->data; |
|
285 |
+ int ret, x, y, toffset, boffset; |
|
286 |
+ AVFrame * const p = data; |
|
287 |
+ GetBitContext gb; |
|
288 |
+ uint8_t *dst; |
|
289 |
+ |
|
290 |
+ if (avpkt->size <= 16) |
|
291 |
+ return AVERROR_INVALIDDATA; |
|
292 |
+ |
|
293 |
+ if (AV_RL32(buf) != MKTAG('Y', 'L', 'C', '0') || |
|
294 |
+ AV_RL32(buf + 4) != 0) |
|
295 |
+ return AVERROR_INVALIDDATA; |
|
296 |
+ |
|
297 |
+ toffset = AV_RL32(buf + 8); |
|
298 |
+ if (toffset < 16 || toffset >= avpkt->size) |
|
299 |
+ return AVERROR_INVALIDDATA; |
|
300 |
+ |
|
301 |
+ boffset = AV_RL32(buf + 12); |
|
302 |
+ if (toffset >= boffset || boffset >= avpkt->size) |
|
303 |
+ return AVERROR_INVALIDDATA; |
|
304 |
+ |
|
305 |
+ if ((ret = ff_get_buffer(avctx, p, 0)) < 0) |
|
306 |
+ return ret; |
|
307 |
+ |
|
308 |
+ av_fast_malloc(&s->table_bits, &s->table_bits_size, |
|
309 |
+ boffset - toffset + AV_INPUT_BUFFER_PADDING_SIZE); |
|
310 |
+ if (!s->table_bits) |
|
311 |
+ return AVERROR(ENOMEM); |
|
312 |
+ |
|
313 |
+ memcpy(s->table_bits, avpkt->data + toffset, boffset - toffset); |
|
314 |
+ memset(s->table_bits + boffset - toffset, 0, AV_INPUT_BUFFER_PADDING_SIZE); |
|
315 |
+ s->bdsp.bswap_buf((uint32_t *) s->table_bits, |
|
316 |
+ (uint32_t *) s->table_bits, |
|
317 |
+ (boffset - toffset + 3) >> 2); |
|
318 |
+ if ((ret = init_get_bits8(&gb, s->table_bits, boffset - toffset)) < 0) |
|
319 |
+ return ret; |
|
320 |
+ |
|
321 |
+ for (x = 0; x < 1024; x++) { |
|
322 |
+ unsigned len = get_unary(&gb, 1, 31); |
|
323 |
+ uint32_t val = ((1U << len) - 1) + get_bits_long(&gb, len); |
|
324 |
+ |
|
325 |
+ s->table[x] = val; |
|
326 |
+ } |
|
327 |
+ |
|
328 |
+ ret = build_vlc(avctx, &s->vlc[0], &s->table[0 ]); |
|
329 |
+ if (ret < 0) |
|
330 |
+ return ret; |
|
331 |
+ ret = build_vlc(avctx, &s->vlc[1], &s->table[256]); |
|
332 |
+ if (ret < 0) |
|
333 |
+ return ret; |
|
334 |
+ ret = build_vlc(avctx, &s->vlc[2], &s->table[512]); |
|
335 |
+ if (ret < 0) |
|
336 |
+ return ret; |
|
337 |
+ ret = build_vlc(avctx, &s->vlc[3], &s->table[768]); |
|
338 |
+ if (ret < 0) |
|
339 |
+ return ret; |
|
340 |
+ |
|
341 |
+ av_fast_malloc(&s->bitstream_bits, &s->bitstream_bits_size, |
|
342 |
+ avpkt->size - boffset + AV_INPUT_BUFFER_PADDING_SIZE); |
|
343 |
+ if (!s->bitstream_bits) |
|
344 |
+ return AVERROR(ENOMEM); |
|
345 |
+ |
|
346 |
+ memcpy(s->bitstream_bits, avpkt->data + boffset, avpkt->size - boffset); |
|
347 |
+ memset(s->bitstream_bits + avpkt->size - boffset, 0, AV_INPUT_BUFFER_PADDING_SIZE); |
|
348 |
+ s->bdsp.bswap_buf((uint32_t *) s->bitstream_bits, |
|
349 |
+ (uint32_t *) s->bitstream_bits, |
|
350 |
+ (avpkt->size - boffset) >> 2); |
|
351 |
+ if ((ret = init_get_bits8(&gb, s->bitstream_bits, avpkt->size - boffset)) < 0) |
|
352 |
+ return ret; |
|
353 |
+ |
|
354 |
+ dst = p->data[0]; |
|
355 |
+ for (y = 0; y < avctx->height; y++) { |
|
356 |
+ memset(dst, 0, avctx->width * 2); |
|
357 |
+ dst += p->linesize[0]; |
|
358 |
+ } |
|
359 |
+ |
|
360 |
+ dst = p->data[0]; |
|
361 |
+ for (y = 0; y < avctx->height; y++) { |
|
362 |
+ for (x = 0; x < avctx->width * 2 && y < avctx->height;) { |
|
363 |
+ if (get_bits_left(&gb) <= 0) |
|
364 |
+ return AVERROR_INVALIDDATA; |
|
365 |
+ |
|
366 |
+ if (get_bits1(&gb)) { |
|
367 |
+ int val = get_vlc2(&gb, s->vlc[0].table, s->vlc[0].bits, 3); |
|
368 |
+ if (val < 0) { |
|
369 |
+ return AVERROR_INVALIDDATA; |
|
370 |
+ } else if (val < 0xE1) { |
|
371 |
+ dst[x ] = table_y1[val]; |
|
372 |
+ dst[x + 1] = table_u[val]; |
|
373 |
+ dst[x + 2] = table_y2[val]; |
|
374 |
+ dst[x + 3] = table_v[val]; |
|
375 |
+ x += 4; |
|
376 |
+ } else { |
|
377 |
+ int incr = (val - 0xDF) * 4; |
|
378 |
+ if (x + incr >= avctx->width * 2) { |
|
379 |
+ int iy = ((x + incr) / (avctx->width * 2)); |
|
380 |
+ x = (x + incr) % (avctx->width * 2); |
|
381 |
+ y += iy; |
|
382 |
+ dst += iy * p->linesize[0]; |
|
383 |
+ } else { |
|
384 |
+ x += incr; |
|
385 |
+ } |
|
386 |
+ } |
|
387 |
+ } else { |
|
388 |
+ int y1, y2, u, v; |
|
389 |
+ |
|
390 |
+ y1 = get_vlc2(&gb, s->vlc[1].table, s->vlc[1].bits, 3); |
|
391 |
+ u = get_vlc2(&gb, s->vlc[2].table, s->vlc[2].bits, 3); |
|
392 |
+ y2 = get_vlc2(&gb, s->vlc[1].table, s->vlc[1].bits, 3); |
|
393 |
+ v = get_vlc2(&gb, s->vlc[3].table, s->vlc[3].bits, 3); |
|
394 |
+ if (y1 < 0 || y2 < 0 || u < 0 || v < 0) |
|
395 |
+ return AVERROR_INVALIDDATA; |
|
396 |
+ dst[x ] = y1; |
|
397 |
+ dst[x + 1] = u; |
|
398 |
+ dst[x + 2] = y1 + y2; |
|
399 |
+ dst[x + 3] = v; |
|
400 |
+ x += 4; |
|
401 |
+ } |
|
402 |
+ } |
|
403 |
+ dst += p->linesize[0]; |
|
404 |
+ } |
|
405 |
+ |
|
406 |
+ dst = p->data[0]; |
|
407 |
+ for (x = 0; x < avctx->width * 2; x += 4) { |
|
408 |
+ dst[x ] = dst[x ] + L[0]; |
|
409 |
+ dst[x + 2] = L[0] = dst[x + 2] + L[0]; |
|
410 |
+ L[1] = dst[x + 1] + L[1]; |
|
411 |
+ dst[x + 1] = L[1]; |
|
412 |
+ L[2] = dst[x + 3] + L[2]; |
|
413 |
+ dst[x + 3] = L[2]; |
|
414 |
+ } |
|
415 |
+ dst += p->linesize[0]; |
|
416 |
+ |
|
417 |
+ for (y = 1; y < avctx->height; y++) { |
|
418 |
+ x = 0; |
|
419 |
+ dst[x ] = dst[x ] + L[0] + dst[x + 0 - p->linesize[0]] - TL[0]; |
|
420 |
+ dst[x + 2] = L[0] = dst[x + 2] + L[0] + dst[x + 2 - p->linesize[0]] - TL[0]; |
|
421 |
+ TL[0] = dst[x + 2 - p->linesize[0]]; |
|
422 |
+ L[1] = dst[x + 1] + L[1] + dst[x + 1 - p->linesize[0]] - TL[1]; |
|
423 |
+ dst[x + 1] = L[1]; |
|
424 |
+ TL[1] = dst[x + 1 - p->linesize[0]]; |
|
425 |
+ L[2] = dst[x + 3] + L[2] + dst[x + 3 - p->linesize[0]] - TL[2]; |
|
426 |
+ dst[x + 3] = L[2]; |
|
427 |
+ TL[2] = dst[x + 3 - p->linesize[0]]; |
|
428 |
+ for (x = 4; x < avctx->width * 2; x += 4) { |
|
429 |
+ dst[x ] = dst[x ] + L[0] + dst[x + 0 - p->linesize[0]] - TL[0]; |
|
430 |
+ dst[x + 2] = L[0] = dst[x + 2] + L[0] + dst[x + 2 - p->linesize[0]] - TL[0]; |
|
431 |
+ TL[0] = dst[x + 2 - p->linesize[0]]; |
|
432 |
+ L[1] = dst[x + 1] + L[1] + dst[x + 1 - p->linesize[0]] - TL[1]; |
|
433 |
+ dst[x + 1] = L[1]; |
|
434 |
+ TL[1] = dst[x + 1 - p->linesize[0]]; |
|
435 |
+ L[2] = dst[x + 3] + L[2] + dst[x + 3 - p->linesize[0]] - TL[2]; |
|
436 |
+ dst[x + 3] = L[2]; |
|
437 |
+ TL[2] = dst[x + 3 - p->linesize[0]]; |
|
438 |
+ } |
|
439 |
+ dst += p->linesize[0]; |
|
440 |
+ } |
|
441 |
+ |
|
442 |
+ p->pict_type = AV_PICTURE_TYPE_I; |
|
443 |
+ p->key_frame = 1; |
|
444 |
+ *got_frame = 1; |
|
445 |
+ |
|
446 |
+ return avpkt->size; |
|
447 |
+} |
|
448 |
+ |
|
449 |
+static av_cold int decode_end(AVCodecContext *avctx) |
|
450 |
+{ |
|
451 |
+ YLCContext *s = avctx->priv_data; |
|
452 |
+ |
|
453 |
+ ff_free_vlc(&s->vlc[0]); |
|
454 |
+ ff_free_vlc(&s->vlc[1]); |
|
455 |
+ ff_free_vlc(&s->vlc[2]); |
|
456 |
+ ff_free_vlc(&s->vlc[3]); |
|
457 |
+ |
|
458 |
+ return 0; |
|
459 |
+} |
|
460 |
+ |
|
461 |
+AVCodec ff_ylc_decoder = { |
|
462 |
+ .name = "ylc", |
|
463 |
+ .long_name = NULL_IF_CONFIG_SMALL("YUY2 Lossless Codec"), |
|
464 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
465 |
+ .id = AV_CODEC_ID_YLC, |
|
466 |
+ .priv_data_size = sizeof(YLCContext), |
|
467 |
+ .init = decode_init, |
|
468 |
+ .close = decode_end, |
|
469 |
+ .decode = decode_frame, |
|
470 |
+ .capabilities = AV_CODEC_CAP_DR1, |
|
471 |
+}; |
... | ... |
@@ -203,15 +203,15 @@ |
203 | 203 |
* avio_open2() or a custom one. |
204 | 204 |
* - Unless the format is of the AVFMT_NOSTREAMS type, at least one stream must |
205 | 205 |
* be created with the avformat_new_stream() function. The caller should fill |
206 |
- * the @ref AVStream.codec "stream codec context" information, such as the |
|
207 |
- * codec @ref AVCodecContext.codec_type "type", @ref AVCodecContext.codec_id |
|
206 |
+ * the @ref AVStream.codecpar "stream codec parameters" information, such as the |
|
207 |
+ * codec @ref AVCodecParameters.codec_type "type", @ref AVCodecParameters.codec_id |
|
208 | 208 |
* "id" and other parameters (e.g. width / height, the pixel or sample format, |
209 | 209 |
* etc.) as known. The @ref AVStream.time_base "stream timebase" should |
210 | 210 |
* be set to the timebase that the caller desires to use for this stream (note |
211 | 211 |
* that the timebase actually used by the muxer can be different, as will be |
212 | 212 |
* described later). |
213 | 213 |
* - It is advised to manually initialize only the relevant fields in |
214 |
- * AVCodecContext, rather than using @ref avcodec_copy_context() during |
|
214 |
+ * AVCodecParameters, rather than using @ref avcodec_parameters_copy() during |
|
215 | 215 |
* remuxing: there is no guarantee that the codec context values remain valid |
216 | 216 |
* for both input and output format contexts. |
217 | 217 |
* - The caller may fill in additional information, such as @ref |
... | ... |
@@ -252,7 +252,6 @@ static void dump_replaygain(void *ctx, AVPacketSideData *sd) |
252 | 252 |
static void dump_stereo3d(void *ctx, AVPacketSideData *sd) |
253 | 253 |
{ |
254 | 254 |
AVStereo3D *stereo; |
255 |
- const char *name; |
|
256 | 255 |
|
257 | 256 |
if (sd->size < sizeof(*stereo)) { |
258 | 257 |
av_log(ctx, AV_LOG_INFO, "invalid data"); |
... | ... |
@@ -424,6 +424,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { |
424 | 424 |
{ AV_CODEC_ID_M101, MKTAG('M', '1', '0', '1') }, |
425 | 425 |
{ AV_CODEC_ID_M101, MKTAG('M', '1', '0', '2') }, |
426 | 426 |
{ AV_CODEC_ID_MAGICYUV, MKTAG('M', 'A', 'G', 'Y') }, |
427 |
+ { AV_CODEC_ID_YLC, MKTAG('Y', 'L', 'C', '0') }, |
|
427 | 428 |
|
428 | 429 |
{ AV_CODEC_ID_NONE, 0 } |
429 | 430 |
}; |
... | ... |
@@ -60,19 +60,19 @@ static void send_picture(AVFormatContext *ctx, const uint8_t *buf, int size, int |
60 | 60 |
second_field = interlaced && (pic_nr & 0x01); |
61 | 61 |
|
62 | 62 |
init_get_bits(&gc, buf, 8 * size); |
63 |
- svq3_get_ue_golomb(&gc); /* wavelet_idx */ |
|
64 |
- wavelet_depth = svq3_get_ue_golomb(&gc); |
|
65 |
- svq3_get_ue_golomb(&gc); /* num_x */ |
|
66 |
- svq3_get_ue_golomb(&gc); /* num_y */ |
|
67 |
- prefix_bytes = svq3_get_ue_golomb(&gc); |
|
68 |
- size_scaler = svq3_get_ue_golomb(&gc); |
|
63 |
+ get_interleaved_ue_golomb(&gc); /* wavelet_idx */ |
|
64 |
+ wavelet_depth = get_interleaved_ue_golomb(&gc); |
|
65 |
+ get_interleaved_ue_golomb(&gc); /* num_x */ |
|
66 |
+ get_interleaved_ue_golomb(&gc); /* num_y */ |
|
67 |
+ prefix_bytes = get_interleaved_ue_golomb(&gc); |
|
68 |
+ size_scaler = get_interleaved_ue_golomb(&gc); |
|
69 | 69 |
/* pass the quantization matrices */ |
70 |
- svq3_get_ue_golomb(&gc); |
|
70 |
+ get_interleaved_ue_golomb(&gc); |
|
71 | 71 |
for(lvl = 0; lvl < wavelet_depth; lvl++) |
72 | 72 |
{ |
73 |
- svq3_get_ue_golomb(&gc); |
|
74 |
- svq3_get_ue_golomb(&gc); |
|
75 |
- svq3_get_ue_golomb(&gc); |
|
73 |
+ get_interleaved_ue_golomb(&gc); |
|
74 |
+ get_interleaved_ue_golomb(&gc); |
|
75 |
+ get_interleaved_ue_golomb(&gc); |
|
76 | 76 |
} |
77 | 77 |
|
78 | 78 |
frag_len = (get_bits_count(&gc) + 7) / 8; /* length of transform parameters */ |
... | ... |
@@ -248,7 +248,7 @@ static int sdp_parse_rtpmap(AVFormatContext *s, |
248 | 248 |
AVCodecParameters *par = st->codecpar; |
249 | 249 |
char buf[256]; |
250 | 250 |
int i; |
251 |
- AVCodec *c; |
|
251 |
+ const AVCodecDescriptor *desc; |
|
252 | 252 |
const char *c_name; |
253 | 253 |
|
254 | 254 |
/* See if we can handle this kind of payload. |
... | ... |
@@ -274,9 +274,9 @@ static int sdp_parse_rtpmap(AVFormatContext *s, |
274 | 274 |
par->codec_id = ff_rtp_codec_id(buf, par->codec_type); |
275 | 275 |
} |
276 | 276 |
|
277 |
- c = avcodec_find_decoder(par->codec_id); |
|
278 |
- if (c && c->name) |
|
279 |
- c_name = c->name; |
|
277 |
+ desc = avcodec_descriptor_get(par->codec_id); |
|
278 |
+ if (desc && desc->name) |
|
279 |
+ c_name = desc->name; |
|
280 | 280 |
else |
281 | 281 |
c_name = "(null)"; |
282 | 282 |
|
... | ... |
@@ -452,3 +452,39 @@ void av_hwframe_constraints_free(AVHWFramesConstraints **constraints) |
452 | 452 |
} |
453 | 453 |
av_freep(constraints); |
454 | 454 |
} |
455 |
+ |
|
456 |
+int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type, |
|
457 |
+ const char *device, AVDictionary *opts, int flags) |
|
458 |
+{ |
|
459 |
+ AVBufferRef *device_ref = NULL; |
|
460 |
+ AVHWDeviceContext *device_ctx; |
|
461 |
+ int ret = 0; |
|
462 |
+ |
|
463 |
+ device_ref = av_hwdevice_ctx_alloc(type); |
|
464 |
+ if (!device_ref) { |
|
465 |
+ ret = AVERROR(ENOMEM); |
|
466 |
+ goto fail; |
|
467 |
+ } |
|
468 |
+ device_ctx = (AVHWDeviceContext*)device_ref->data; |
|
469 |
+ |
|
470 |
+ if (!device_ctx->internal->hw_type->device_create) { |
|
471 |
+ ret = AVERROR(ENOSYS); |
|
472 |
+ goto fail; |
|
473 |
+ } |
|
474 |
+ |
|
475 |
+ ret = device_ctx->internal->hw_type->device_create(device_ctx, device, |
|
476 |
+ opts, flags); |
|
477 |
+ if (ret < 0) |
|
478 |
+ goto fail; |
|
479 |
+ |
|
480 |
+ ret = av_hwdevice_ctx_init(device_ref); |
|
481 |
+ if (ret < 0) |
|
482 |
+ goto fail; |
|
483 |
+ |
|
484 |
+ *pdevice_ref = device_ref; |
|
485 |
+ return 0; |
|
486 |
+fail: |
|
487 |
+ av_buffer_unref(&device_ref); |
|
488 |
+ *pdevice_ref = NULL; |
|
489 |
+ return ret; |
|
490 |
+} |
... | ... |
@@ -242,6 +242,34 @@ AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type); |
242 | 242 |
int av_hwdevice_ctx_init(AVBufferRef *ref); |
243 | 243 |
|
244 | 244 |
/** |
245 |
+ * Open a device of the specified type and create an AVHWDeviceContext for it. |
|
246 |
+ * |
|
247 |
+ * This is a convenience function intended to cover the simple cases. Callers |
|
248 |
+ * who need to fine-tune device creation/management should open the device |
|
249 |
+ * manually and then wrap it in an AVHWDeviceContext using |
|
250 |
+ * av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init(). |
|
251 |
+ * |
|
252 |
+ * The returned context is already initialized and ready for use, the caller |
|
253 |
+ * should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of |
|
254 |
+ * the created AVHWDeviceContext are set by this function and should not be |
|
255 |
+ * touched by the caller. |
|
256 |
+ * |
|
257 |
+ * @param device_ctx On success, a reference to the newly-created device context |
|
258 |
+ * will be written here. The reference is owned by the caller |
|
259 |
+ * and must be released with av_buffer_unref() when no longer |
|
260 |
+ * needed. On failure, NULL will be written to this pointer. |
|
261 |
+ * @param type The type of the device to create. |
|
262 |
+ * @param device A type-specific string identifying the device to open. |
|
263 |
+ * @param opts A dictionary of additional (type-specific) options to use in |
|
264 |
+ * opening the device. The dictionary remains owned by the caller. |
|
265 |
+ * @param flags currently unused |
|
266 |
+ * |
|
267 |
+ * @return 0 on success, a negative AVERROR code on failure. |
|
268 |
+ */ |
|
269 |
+int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type, |
|
270 |
+ const char *device, AVDictionary *opts, int flags); |
|
271 |
+ |
|
272 |
+/** |
|
245 | 273 |
* Allocate an AVHWFramesContext tied to a given device context. |
246 | 274 |
* |
247 | 275 |
* @param device_ctx a reference to a AVHWDeviceContext. This function will make |
... | ... |
@@ -253,6 +253,49 @@ static int cuda_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, |
253 | 253 |
return 0; |
254 | 254 |
} |
255 | 255 |
|
256 |
+static void cuda_device_free(AVHWDeviceContext *ctx) |
|
257 |
+{ |
|
258 |
+ AVCUDADeviceContext *hwctx = ctx->hwctx; |
|
259 |
+ cuCtxDestroy(hwctx->cuda_ctx); |
|
260 |
+} |
|
261 |
+ |
|
262 |
+static int cuda_device_create(AVHWDeviceContext *ctx, const char *device, |
|
263 |
+ AVDictionary *opts, int flags) |
|
264 |
+{ |
|
265 |
+ AVCUDADeviceContext *hwctx = ctx->hwctx; |
|
266 |
+ CUdevice cu_device; |
|
267 |
+ CUcontext dummy; |
|
268 |
+ CUresult err; |
|
269 |
+ int device_idx = 0; |
|
270 |
+ |
|
271 |
+ if (device) |
|
272 |
+ device_idx = strtol(device, NULL, 0); |
|
273 |
+ |
|
274 |
+ err = cuInit(0); |
|
275 |
+ if (err != CUDA_SUCCESS) { |
|
276 |
+ av_log(ctx, AV_LOG_ERROR, "Could not initialize the CUDA driver API\n"); |
|
277 |
+ return AVERROR_UNKNOWN; |
|
278 |
+ } |
|
279 |
+ |
|
280 |
+ err = cuDeviceGet(&cu_device, device_idx); |
|
281 |
+ if (err != CUDA_SUCCESS) { |
|
282 |
+ av_log(ctx, AV_LOG_ERROR, "Could not get the device number %d\n", device_idx); |
|
283 |
+ return AVERROR_UNKNOWN; |
|
284 |
+ } |
|
285 |
+ |
|
286 |
+ err = cuCtxCreate(&hwctx->cuda_ctx, 0, cu_device); |
|
287 |
+ if (err != CUDA_SUCCESS) { |
|
288 |
+ av_log(ctx, AV_LOG_ERROR, "Error creating a CUDA context\n"); |
|
289 |
+ return AVERROR_UNKNOWN; |
|
290 |
+ } |
|
291 |
+ |
|
292 |
+ cuCtxPopCurrent(&dummy); |
|
293 |
+ |
|
294 |
+ ctx->free = cuda_device_free; |
|
295 |
+ |
|
296 |
+ return 0; |
|
297 |
+} |
|
298 |
+ |
|
256 | 299 |
const HWContextType ff_hwcontext_type_cuda = { |
257 | 300 |
.type = AV_HWDEVICE_TYPE_CUDA, |
258 | 301 |
.name = "CUDA", |
... | ... |
@@ -260,6 +303,7 @@ const HWContextType ff_hwcontext_type_cuda = { |
260 | 260 |
.device_hwctx_size = sizeof(AVCUDADeviceContext), |
261 | 261 |
.frames_priv_size = sizeof(CUDAFramesContext), |
262 | 262 |
|
263 |
+ .device_create = cuda_device_create, |
|
263 | 264 |
.frames_init = cuda_frames_init, |
264 | 265 |
.frames_get_buffer = cuda_get_buffer, |
265 | 266 |
.transfer_get_formats = cuda_transfer_get_formats, |
... | ... |
@@ -38,6 +38,9 @@ |
38 | 38 |
#include "pixdesc.h" |
39 | 39 |
#include "pixfmt.h" |
40 | 40 |
|
41 |
+typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT); |
|
42 |
+typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **); |
|
43 |
+ |
|
41 | 44 |
typedef struct DXVA2FramesContext { |
42 | 45 |
IDirect3DSurface9 **surfaces_internal; |
43 | 46 |
int nb_surfaces_used; |
... | ... |
@@ -48,6 +51,16 @@ typedef struct DXVA2FramesContext { |
48 | 48 |
D3DFORMAT format; |
49 | 49 |
} DXVA2FramesContext; |
50 | 50 |
|
51 |
+typedef struct DXVA2DevicePriv { |
|
52 |
+ HMODULE d3dlib; |
|
53 |
+ HMODULE dxva2lib; |
|
54 |
+ |
|
55 |
+ HANDLE device_handle; |
|
56 |
+ |
|
57 |
+ IDirect3D9 *d3d9; |
|
58 |
+ IDirect3DDevice9 *d3d9device; |
|
59 |
+} DXVA2DevicePriv; |
|
60 |
+ |
|
51 | 61 |
static const struct { |
52 | 62 |
D3DFORMAT d3d_format; |
53 | 63 |
enum AVPixelFormat pix_fmt; |
... | ... |
@@ -287,6 +300,125 @@ static int dxva2_transfer_data(AVHWFramesContext *ctx, AVFrame *dst, |
287 | 287 |
return 0; |
288 | 288 |
} |
289 | 289 |
|
290 |
+static void dxva2_device_free(AVHWDeviceContext *ctx) |
|
291 |
+{ |
|
292 |
+ AVDXVA2DeviceContext *hwctx = ctx->hwctx; |
|
293 |
+ DXVA2DevicePriv *priv = ctx->user_opaque; |
|
294 |
+ |
|
295 |
+ if (hwctx->devmgr && priv->device_handle != INVALID_HANDLE_VALUE) |
|
296 |
+ IDirect3DDeviceManager9_CloseDeviceHandle(hwctx->devmgr, priv->device_handle); |
|
297 |
+ |
|
298 |
+ if (hwctx->devmgr) |
|
299 |
+ IDirect3DDeviceManager9_Release(hwctx->devmgr); |
|
300 |
+ |
|
301 |
+ if (priv->d3d9device) |
|
302 |
+ IDirect3DDevice9_Release(priv->d3d9device); |
|
303 |
+ |
|
304 |
+ if (priv->d3d9) |
|
305 |
+ IDirect3D9_Release(priv->d3d9); |
|
306 |
+ |
|
307 |
+ if (priv->d3dlib) |
|
308 |
+ FreeLibrary(priv->d3dlib); |
|
309 |
+ |
|
310 |
+ if (priv->dxva2lib) |
|
311 |
+ FreeLibrary(priv->dxva2lib); |
|
312 |
+ |
|
313 |
+ av_freep(&ctx->user_opaque); |
|
314 |
+} |
|
315 |
+ |
|
316 |
+static int dxva2_device_create(AVHWDeviceContext *ctx, const char *device, |
|
317 |
+ AVDictionary *opts, int flags) |
|
318 |
+{ |
|
319 |
+ AVDXVA2DeviceContext *hwctx = ctx->hwctx; |
|
320 |
+ DXVA2DevicePriv *priv; |
|
321 |
+ |
|
322 |
+ pDirect3DCreate9 *createD3D = NULL; |
|
323 |
+ pCreateDeviceManager9 *createDeviceManager = NULL; |
|
324 |
+ D3DPRESENT_PARAMETERS d3dpp = {0}; |
|
325 |
+ D3DDISPLAYMODE d3ddm; |
|
326 |
+ unsigned resetToken = 0; |
|
327 |
+ UINT adapter = D3DADAPTER_DEFAULT; |
|
328 |
+ HRESULT hr; |
|
329 |
+ |
|
330 |
+ if (device) |
|
331 |
+ adapter = atoi(device); |
|
332 |
+ |
|
333 |
+ priv = av_mallocz(sizeof(*priv)); |
|
334 |
+ if (!priv) |
|
335 |
+ return AVERROR(ENOMEM); |
|
336 |
+ |
|
337 |
+ ctx->user_opaque = priv; |
|
338 |
+ ctx->free = dxva2_device_free; |
|
339 |
+ |
|
340 |
+ priv->device_handle = INVALID_HANDLE_VALUE; |
|
341 |
+ |
|
342 |
+ priv->d3dlib = LoadLibrary("d3d9.dll"); |
|
343 |
+ if (!priv->d3dlib) { |
|
344 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to load D3D9 library\n"); |
|
345 |
+ return AVERROR_UNKNOWN; |
|
346 |
+ } |
|
347 |
+ priv->dxva2lib = LoadLibrary("dxva2.dll"); |
|
348 |
+ if (!priv->dxva2lib) { |
|
349 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to load DXVA2 library\n"); |
|
350 |
+ return AVERROR_UNKNOWN; |
|
351 |
+ } |
|
352 |
+ |
|
353 |
+ createD3D = (pDirect3DCreate9 *)GetProcAddress(priv->d3dlib, "Direct3DCreate9"); |
|
354 |
+ if (!createD3D) { |
|
355 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to locate Direct3DCreate9\n"); |
|
356 |
+ return AVERROR_UNKNOWN; |
|
357 |
+ } |
|
358 |
+ createDeviceManager = (pCreateDeviceManager9 *)GetProcAddress(priv->dxva2lib, |
|
359 |
+ "DXVA2CreateDirect3DDeviceManager9"); |
|
360 |
+ if (!createDeviceManager) { |
|
361 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to locate DXVA2CreateDirect3DDeviceManager9\n"); |
|
362 |
+ return AVERROR_UNKNOWN; |
|
363 |
+ } |
|
364 |
+ |
|
365 |
+ priv->d3d9 = createD3D(D3D_SDK_VERSION); |
|
366 |
+ if (!priv->d3d9) { |
|
367 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to create IDirect3D object\n"); |
|
368 |
+ return AVERROR_UNKNOWN; |
|
369 |
+ } |
|
370 |
+ |
|
371 |
+ IDirect3D9_GetAdapterDisplayMode(priv->d3d9, adapter, &d3ddm); |
|
372 |
+ d3dpp.Windowed = TRUE; |
|
373 |
+ d3dpp.BackBufferWidth = 640; |
|
374 |
+ d3dpp.BackBufferHeight = 480; |
|
375 |
+ d3dpp.BackBufferCount = 0; |
|
376 |
+ d3dpp.BackBufferFormat = d3ddm.Format; |
|
377 |
+ d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; |
|
378 |
+ d3dpp.Flags = D3DPRESENTFLAG_VIDEO; |
|
379 |
+ |
|
380 |
+ hr = IDirect3D9_CreateDevice(priv->d3d9, adapter, D3DDEVTYPE_HAL, GetDesktopWindow(), |
|
381 |
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, |
|
382 |
+ &d3dpp, &priv->d3d9device); |
|
383 |
+ if (FAILED(hr)) { |
|
384 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to create Direct3D device\n"); |
|
385 |
+ return AVERROR_UNKNOWN; |
|
386 |
+ } |
|
387 |
+ |
|
388 |
+ hr = createDeviceManager(&resetToken, &hwctx->devmgr); |
|
389 |
+ if (FAILED(hr)) { |
|
390 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to create Direct3D device manager\n"); |
|
391 |
+ return AVERROR_UNKNOWN; |
|
392 |
+ } |
|
393 |
+ |
|
394 |
+ hr = IDirect3DDeviceManager9_ResetDevice(hwctx->devmgr, priv->d3d9device, resetToken); |
|
395 |
+ if (FAILED(hr)) { |
|
396 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to bind Direct3D device to device manager\n"); |
|
397 |
+ return AVERROR_UNKNOWN; |
|
398 |
+ } |
|
399 |
+ |
|
400 |
+ hr = IDirect3DDeviceManager9_OpenDeviceHandle(hwctx->devmgr, &priv->device_handle); |
|
401 |
+ if (FAILED(hr)) { |
|
402 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to open device handle\n"); |
|
403 |
+ return AVERROR_UNKNOWN; |
|
404 |
+ } |
|
405 |
+ |
|
406 |
+ return 0; |
|
407 |
+} |
|
408 |
+ |
|
290 | 409 |
const HWContextType ff_hwcontext_type_dxva2 = { |
291 | 410 |
.type = AV_HWDEVICE_TYPE_DXVA2, |
292 | 411 |
.name = "DXVA2", |
... | ... |
@@ -295,6 +427,7 @@ const HWContextType ff_hwcontext_type_dxva2 = { |
295 | 295 |
.frames_hwctx_size = sizeof(AVDXVA2FramesContext), |
296 | 296 |
.frames_priv_size = sizeof(DXVA2FramesContext), |
297 | 297 |
|
298 |
+ .device_create = dxva2_device_create, |
|
298 | 299 |
.frames_init = dxva2_frames_init, |
299 | 300 |
.frames_uninit = dxva2_frames_uninit, |
300 | 301 |
.frames_get_buffer = dxva2_get_buffer, |
... | ... |
@@ -64,6 +64,9 @@ typedef struct HWContextType { |
64 | 64 |
*/ |
65 | 65 |
size_t frames_priv_size; |
66 | 66 |
|
67 |
+ int (*device_create)(AVHWDeviceContext *ctx, const char *device, |
|
68 |
+ AVDictionary *opts, int flags); |
|
69 |
+ |
|
67 | 70 |
int (*device_init)(AVHWDeviceContext *ctx); |
68 | 71 |
void (*device_uninit)(AVHWDeviceContext *ctx); |
69 | 72 |
|
... | ... |
@@ -16,6 +16,21 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17 | 17 |
*/ |
18 | 18 |
|
19 |
+#include "config.h" |
|
20 |
+ |
|
21 |
+#if HAVE_VAAPI_X11 |
|
22 |
+# include <va/va_x11.h> |
|
23 |
+#endif |
|
24 |
+#if HAVE_VAAPI_DRM |
|
25 |
+# include <va/va_drm.h> |
|
26 |
+#endif |
|
27 |
+ |
|
28 |
+#include <fcntl.h> |
|
29 |
+#if HAVE_UNISTD_H |
|
30 |
+# include <unistd.h> |
|
31 |
+#endif |
|
32 |
+ |
|
33 |
+ |
|
19 | 34 |
#include "avassert.h" |
20 | 35 |
#include "buffer.h" |
21 | 36 |
#include "common.h" |
... | ... |
@@ -26,6 +41,14 @@ |
26 | 26 |
#include "pixdesc.h" |
27 | 27 |
#include "pixfmt.h" |
28 | 28 |
|
29 |
+typedef struct VAAPIDevicePriv { |
|
30 |
+#if HAVE_VAAPI_X11 |
|
31 |
+ Display *x11_display; |
|
32 |
+#endif |
|
33 |
+ |
|
34 |
+ int drm_fd; |
|
35 |
+} VAAPIDevicePriv; |
|
36 |
+ |
|
29 | 37 |
typedef struct VAAPISurfaceFormat { |
30 | 38 |
enum AVPixelFormat pix_fmt; |
31 | 39 |
VAImageFormat image_format; |
... | ... |
@@ -823,6 +846,105 @@ fail: |
823 | 823 |
return err; |
824 | 824 |
} |
825 | 825 |
|
826 |
+static void vaapi_device_free(AVHWDeviceContext *ctx) |
|
827 |
+{ |
|
828 |
+ AVVAAPIDeviceContext *hwctx = ctx->hwctx; |
|
829 |
+ VAAPIDevicePriv *priv = ctx->user_opaque; |
|
830 |
+ |
|
831 |
+ if (hwctx->display) |
|
832 |
+ vaTerminate(hwctx->display); |
|
833 |
+ |
|
834 |
+#if HAVE_VAAPI_X11 |
|
835 |
+ if (priv->x11_display) |
|
836 |
+ XCloseDisplay(priv->x11_display); |
|
837 |
+#endif |
|
838 |
+ |
|
839 |
+ if (priv->drm_fd >= 0) |
|
840 |
+ close(priv->drm_fd); |
|
841 |
+ |
|
842 |
+ av_freep(&priv); |
|
843 |
+} |
|
844 |
+ |
|
845 |
+static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, |
|
846 |
+ AVDictionary *opts, int flags) |
|
847 |
+{ |
|
848 |
+ AVVAAPIDeviceContext *hwctx = ctx->hwctx; |
|
849 |
+ VAAPIDevicePriv *priv; |
|
850 |
+ VADisplay display = 0; |
|
851 |
+ VAStatus vas; |
|
852 |
+ int major, minor; |
|
853 |
+ |
|
854 |
+ priv = av_mallocz(sizeof(*priv)); |
|
855 |
+ if (!priv) |
|
856 |
+ return AVERROR(ENOMEM); |
|
857 |
+ |
|
858 |
+ priv->drm_fd = -1; |
|
859 |
+ |
|
860 |
+ ctx->user_opaque = priv; |
|
861 |
+ ctx->free = vaapi_device_free; |
|
862 |
+ |
|
863 |
+#if HAVE_VAAPI_X11 |
|
864 |
+ if (!display && !(device && device[0] == '/')) { |
|
865 |
+ // Try to open the device as an X11 display. |
|
866 |
+ priv->x11_display = XOpenDisplay(device); |
|
867 |
+ if (!priv->x11_display) { |
|
868 |
+ av_log(ctx, AV_LOG_VERBOSE, "Cannot open X11 display " |
|
869 |
+ "%s.\n", XDisplayName(device)); |
|
870 |
+ } else { |
|
871 |
+ display = vaGetDisplay(priv->x11_display); |
|
872 |
+ if (!display) { |
|
873 |
+ av_log(ctx, AV_LOG_ERROR, "Cannot open a VA display " |
|
874 |
+ "from X11 display %s.\n", XDisplayName(device)); |
|
875 |
+ return AVERROR_UNKNOWN; |
|
876 |
+ } |
|
877 |
+ |
|
878 |
+ av_log(ctx, AV_LOG_VERBOSE, "Opened VA display via " |
|
879 |
+ "X11 display %s.\n", XDisplayName(device)); |
|
880 |
+ } |
|
881 |
+ } |
|
882 |
+#endif |
|
883 |
+ |
|
884 |
+#if HAVE_VAAPI_DRM |
|
885 |
+ if (!display && device) { |
|
886 |
+ // Try to open the device as a DRM path. |
|
887 |
+ priv->drm_fd = open(device, O_RDWR); |
|
888 |
+ if (priv->drm_fd < 0) { |
|
889 |
+ av_log(ctx, AV_LOG_VERBOSE, "Cannot open DRM device %s.\n", |
|
890 |
+ device); |
|
891 |
+ } else { |
|
892 |
+ display = vaGetDisplayDRM(priv->drm_fd); |
|
893 |
+ if (!display) { |
|
894 |
+ av_log(ctx, AV_LOG_ERROR, "Cannot open a VA display " |
|
895 |
+ "from DRM device %s.\n", device); |
|
896 |
+ return AVERROR_UNKNOWN; |
|
897 |
+ } |
|
898 |
+ |
|
899 |
+ av_log(ctx, AV_LOG_VERBOSE, "Opened VA display via " |
|
900 |
+ "DRM device %s.\n", device); |
|
901 |
+ } |
|
902 |
+ } |
|
903 |
+#endif |
|
904 |
+ |
|
905 |
+ if (!display) { |
|
906 |
+ av_log(ctx, AV_LOG_ERROR, "No VA display found for " |
|
907 |
+ "device: %s.\n", device ? device : ""); |
|
908 |
+ return AVERROR(EINVAL); |
|
909 |
+ } |
|
910 |
+ |
|
911 |
+ hwctx->display = display; |
|
912 |
+ |
|
913 |
+ vas = vaInitialize(display, &major, &minor); |
|
914 |
+ if (vas != VA_STATUS_SUCCESS) { |
|
915 |
+ av_log(ctx, AV_LOG_ERROR, "Failed to initialise VAAPI " |
|
916 |
+ "connection: %d (%s).\n", vas, vaErrorStr(vas)); |
|
917 |
+ return AVERROR(EIO); |
|
918 |
+ } |
|
919 |
+ av_log(ctx, AV_LOG_VERBOSE, "Initialised VAAPI connection: " |
|
920 |
+ "version %d.%d\n", major, minor); |
|
921 |
+ |
|
922 |
+ return 0; |
|
923 |
+} |
|
924 |
+ |
|
826 | 925 |
const HWContextType ff_hwcontext_type_vaapi = { |
827 | 926 |
.type = AV_HWDEVICE_TYPE_VAAPI, |
828 | 927 |
.name = "VAAPI", |
... | ... |
@@ -833,6 +955,7 @@ const HWContextType ff_hwcontext_type_vaapi = { |
833 | 833 |
.frames_hwctx_size = sizeof(AVVAAPIFramesContext), |
834 | 834 |
.frames_priv_size = sizeof(VAAPIFramesContext), |
835 | 835 |
|
836 |
+ .device_create = &vaapi_device_create, |
|
836 | 837 |
.device_init = &vaapi_device_init, |
837 | 838 |
.device_uninit = &vaapi_device_uninit, |
838 | 839 |
.frames_get_constraints = &vaapi_frames_get_constraints, |
... | ... |
@@ -16,6 +16,8 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17 | 17 |
*/ |
18 | 18 |
|
19 |
+#include "config.h" |
|
20 |
+ |
|
19 | 21 |
#include <stdint.h> |
20 | 22 |
#include <string.h> |
21 | 23 |
|
... | ... |
@@ -388,6 +390,82 @@ static int vdpau_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, |
388 | 388 |
return 0; |
389 | 389 |
} |
390 | 390 |
|
391 |
+#if HAVE_VDPAU_X11 |
|
392 |
+#include <vdpau/vdpau_x11.h> |
|
393 |
+#include <X11/Xlib.h> |
|
394 |
+ |
|
395 |
+typedef struct VDPAUDevicePriv { |
|
396 |
+ VdpDeviceDestroy *device_destroy; |
|
397 |
+ Display *dpy; |
|
398 |
+} VDPAUDevicePriv; |
|
399 |
+ |
|
400 |
+static void vdpau_device_free(AVHWDeviceContext *ctx) |
|
401 |
+{ |
|
402 |
+ AVVDPAUDeviceContext *hwctx = ctx->hwctx; |
|
403 |
+ VDPAUDevicePriv *priv = ctx->user_opaque; |
|
404 |
+ |
|
405 |
+ if (priv->device_destroy) |
|
406 |
+ priv->device_destroy(hwctx->device); |
|
407 |
+ if (priv->dpy) |
|
408 |
+ XCloseDisplay(priv->dpy); |
|
409 |
+ av_freep(&priv); |
|
410 |
+} |
|
411 |
+ |
|
412 |
+static int vdpau_device_create(AVHWDeviceContext *ctx, const char *device, |
|
413 |
+ AVDictionary *opts, int flags) |
|
414 |
+{ |
|
415 |
+ AVVDPAUDeviceContext *hwctx = ctx->hwctx; |
|
416 |
+ |
|
417 |
+ VDPAUDevicePriv *priv; |
|
418 |
+ VdpStatus err; |
|
419 |
+ VdpGetInformationString *get_information_string; |
|
420 |
+ const char *display, *vendor; |
|
421 |
+ |
|
422 |
+ priv = av_mallocz(sizeof(*priv)); |
|
423 |
+ if (!priv) |
|
424 |
+ return AVERROR(ENOMEM); |
|
425 |
+ |
|
426 |
+ ctx->user_opaque = priv; |
|
427 |
+ ctx->free = vdpau_device_free; |
|
428 |
+ |
|
429 |
+ priv->dpy = XOpenDisplay(device); |
|
430 |
+ if (!priv->dpy) { |
|
431 |
+ av_log(ctx, AV_LOG_ERROR, "Cannot open the X11 display %s.\n", |
|
432 |
+ XDisplayName(device)); |
|
433 |
+ return AVERROR_UNKNOWN; |
|
434 |
+ } |
|
435 |
+ display = XDisplayString(priv->dpy); |
|
436 |
+ |
|
437 |
+ err = vdp_device_create_x11(priv->dpy, XDefaultScreen(priv->dpy), |
|
438 |
+ &hwctx->device, &hwctx->get_proc_address); |
|
439 |
+ if (err != VDP_STATUS_OK) { |
|
440 |
+ av_log(ctx, AV_LOG_ERROR, "VDPAU device creation on X11 display %s failed.\n", |
|
441 |
+ display); |
|
442 |
+ return AVERROR_UNKNOWN; |
|
443 |
+ } |
|
444 |
+ |
|
445 |
+#define GET_CALLBACK(id, result) \ |
|
446 |
+do { \ |
|
447 |
+ void *tmp; \ |
|
448 |
+ err = hwctx->get_proc_address(hwctx->device, id, &tmp); \ |
|
449 |
+ if (err != VDP_STATUS_OK) { \ |
|
450 |
+ av_log(ctx, AV_LOG_ERROR, "Error getting the " #id " callback.\n"); \ |
|
451 |
+ return AVERROR_UNKNOWN; \ |
|
452 |
+ } \ |
|
453 |
+ result = tmp; \ |
|
454 |
+} while (0) |
|
455 |
+ |
|
456 |
+ GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string); |
|
457 |
+ GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, priv->device_destroy); |
|
458 |
+ |
|
459 |
+ get_information_string(&vendor); |
|
460 |
+ av_log(ctx, AV_LOG_VERBOSE, "Successfully created a VDPAU device (%s) on " |
|
461 |
+ "X11 display %s\n", vendor, display); |
|
462 |
+ |
|
463 |
+ return 0; |
|
464 |
+} |
|
465 |
+#endif |
|
466 |
+ |
|
391 | 467 |
const HWContextType ff_hwcontext_type_vdpau = { |
392 | 468 |
.type = AV_HWDEVICE_TYPE_VDPAU, |
393 | 469 |
.name = "VDPAU", |
... | ... |
@@ -396,6 +474,9 @@ const HWContextType ff_hwcontext_type_vdpau = { |
396 | 396 |
.device_priv_size = sizeof(VDPAUDeviceContext), |
397 | 397 |
.frames_priv_size = sizeof(VDPAUFramesContext), |
398 | 398 |
|
399 |
+#if HAVE_VDPAU_X11 |
|
400 |
+ .device_create = vdpau_device_create, |
|
401 |
+#endif |
|
399 | 402 |
.device_init = vdpau_device_init, |
400 | 403 |
.device_uninit = vdpau_device_uninit, |
401 | 404 |
.frames_init = vdpau_frames_init, |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
FATE_SAMPLES_DEMUX-$(call DEMDEC, AVI, FRAPS) += fate-avio-direct |
2 | 2 |
fate-avio-direct: CMD = framecrc -avioflags direct -i $(TARGET_SAMPLES)/fraps/fraps-v5-bouncing-balls-partial.avi -avioflags direct |
3 | 3 |
|
4 |
-FATE_SAMPLES_DEMUX-$(CONFIG_AAC_DEMUXER) += fate-adts-demux |
|
4 |
+FATE_SAMPLES_DEMUX-$(DEMDEC, AAC, AAC) += fate-adts-demux |
|
5 | 5 |
fate-adts-demux: CMD = crc -i $(TARGET_SAMPLES)/aac/ct_faac-adts.aac -acodec copy |
6 | 6 |
|
7 | 7 |
FATE_SAMPLES_DEMUX-$(CONFIG_AEA_DEMUXER) += fate-aea-demux |
... | ... |
@@ -41,13 +41,13 @@ fate-flv-demux: CMD = framecrc -i $(TARGET_SAMPLES)/flv/Enigma_Principles_of_Lus |
41 | 41 |
FATE_SAMPLES_DEMUX-$(CONFIG_GIF_DEMUXER) += fate-gif-demux |
42 | 42 |
fate-gif-demux: CMD = framecrc -i $(TARGET_SAMPLES)/gif/Newtons_cradle_animation_book_2.gif -vcodec copy |
43 | 43 |
|
44 |
-FATE_SAMPLES_DEMUX-$(CONFIG_IV8_DEMUXER) += fate-iv8-demux |
|
44 |
+FATE_SAMPLES_DEMUX-$(call ALLYES, IV8_DEMUXER MPEG4VIDEO_PARSER) += fate-iv8-demux |
|
45 | 45 |
fate-iv8-demux: CMD = framecrc -i $(TARGET_SAMPLES)/iv8/zzz-partial.mpg -vcodec copy |
46 | 46 |
|
47 | 47 |
FATE_SAMPLES_DEMUX-$(CONFIG_JV_DEMUXER) += fate-jv-demux |
48 | 48 |
fate-jv-demux: CMD = framecrc -i $(TARGET_SAMPLES)/jv/intro.jv -vcodec copy -acodec copy |
49 | 49 |
|
50 |
-FATE_SAMPLES_DEMUX-$(CONFIG_LMLM4_DEMUXER) += fate-lmlm4-demux |
|
50 |
+FATE_SAMPLES_DEMUX-$(call ALLYES, LMLM4_DEMUXER MPEG4VIDEO_PARSER) += fate-lmlm4-demux |
|
51 | 51 |
fate-lmlm4-demux: CMD = framecrc -i $(TARGET_SAMPLES)/lmlm4/LMLM4_CIFat30fps.divx -t 3 -acodec copy -vcodec copy |
52 | 52 |
|
53 | 53 |
FATE_SAMPLES_DEMUX-$(CONFIG_XA_DEMUXER) += fate-maxis-xa |
... | ... |
@@ -72,10 +72,10 @@ fate-ts-opus-demux: CMD = framecrc -i $(TARGET_SAMPLES)/opus/test-8-7.1.opus-sma |
72 | 72 |
FATE_SAMPLES_DEMUX-$(CONFIG_MTV_DEMUXER) += fate-mtv |
73 | 73 |
fate-mtv: CMD = framecrc -i $(TARGET_SAMPLES)/mtv/comedian_auto-partial.mtv -c copy |
74 | 74 |
|
75 |
-FATE_SAMPLES_DEMUX-$(CONFIG_MXF_DEMUXER) += fate-mxf-demux |
|
75 |
+FATE_SAMPLES_DEMUX-$(call DEMDEC, MXF, MPEG4) += fate-mxf-demux |
|
76 | 76 |
fate-mxf-demux: CMD = framecrc -i $(TARGET_SAMPLES)/mxf/C0023S01.mxf -acodec copy -vcodec copy |
77 | 77 |
|
78 |
-FATE_SAMPLES_DEMUX-$(CONFIG_NC_DEMUXER) += fate-nc-demux |
|
78 |
+FATE_SAMPLES_DEMUX-$(call ALLYES, NC_DEMUXER MPEG4VIDEO_PARSER) += fate-nc-demux |
|
79 | 79 |
fate-nc-demux: CMD = framecrc -i $(TARGET_SAMPLES)/nc-camera/nc-sample-partial -vcodec copy |
80 | 80 |
|
81 | 81 |
FATE_SAMPLES_DEMUX-$(CONFIG_NISTSPHERE_DEMUXER) += fate-nistsphere-demux |
... | ... |
@@ -129,7 +129,7 @@ fate-wav-ac3: CMD = framecrc -i $(TARGET_SAMPLES)/ac3/diatonis_invisible_order_a |
129 | 129 |
FATE_SAMPLES_DEMUX-$(CONFIG_WSAUD_DEMUXER) += fate-westwood-aud |
130 | 130 |
fate-westwood-aud: CMD = framecrc -i $(TARGET_SAMPLES)/westwood-aud/excellent.aud -c copy |
131 | 131 |
|
132 |
-FATE_SAMPLES_DEMUX-$(CONFIG_WTV_DEMUXER) += fate-wtv-demux |
|
132 |
+FATE_SAMPLES_DEMUX-$(call ALLYES, WTV_DEMUXER MPEGVIDEO_PARSER) += fate-wtv-demux |
|
133 | 133 |
fate-wtv-demux: CMD = framecrc -i $(TARGET_SAMPLES)/wtv/law-and-order-partial.wtv -vcodec copy -acodec copy |
134 | 134 |
|
135 | 135 |
FATE_SAMPLES_DEMUX-$(CONFIG_XMV_DEMUXER) += fate-xmv-demux |
... | ... |
@@ -3,7 +3,7 @@ FATE_SCREEN-$(call DEMDEC, AVI, CSCD) += fate-cscd |
3 | 3 |
fate-cscd: CMD = framecrc -i $(TARGET_SAMPLES)/CSCD/sample_video.avi -an -pix_fmt rgb24 |
4 | 4 |
|
5 | 5 |
FATE_SCREEN-$(call DEMDEC, AVI, DXTORY) += fate-dxtory |
6 |
-fate-dxtory: CMD = framecrc -i $(TARGET_SAMPLES)/dxtory/dxtory_mic.avi |
|
6 |
+fate-dxtory: CMD = framecrc -i $(TARGET_SAMPLES)/dxtory/dxtory_mic.avi -an |
|
7 | 7 |
|
8 | 8 |
FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, FIC) += fate-fic-avi |
9 | 9 |
fate-fic-avi: CMD = framecrc -i $(TARGET_SAMPLES)/fic/fic-partial-2MB.avi -an |
... | ... |
@@ -7,7 +7,7 @@ fate-g722-encode: SRC = tests/data/asynth-16000-1.wav |
7 | 7 |
fate-g722-encode: CMD = enc_dec_pcm wav framemd5 s16le $(SRC) -c:a g722 |
8 | 8 |
|
9 | 9 |
FATE_VOICE-yes += $(FATE_G722-yes) |
10 |
-fate-g722: $(FATE_G722) |
|
10 |
+fate-g722: $(FATE_G722-yes) |
|
11 | 11 |
|
12 | 12 |
FATE_G723_1 += fate-g723_1-dec-1 |
13 | 13 |
fate-g723_1-dec-1: CMD = framecrc -postfilter 0 -i $(TARGET_SAMPLES)/g723_1/ineqd53.tco |
... | ... |
@@ -33,8 +33,7 @@ fate-g723_1-dec-7: CMD = framecrc -postfilter 1 -i $(TARGET_SAMPLES)/g723_1/dtx6 |
33 | 33 |
FATE_G723_1 += fate-g723_1-dec-8 |
34 | 34 |
fate-g723_1-dec-8: CMD = framecrc -postfilter 1 -i $(TARGET_SAMPLES)/g723_1/dtx63e.tco |
35 | 35 |
|
36 |
-FATE_G723_1-$(call DEMDEC, G723_1, G723_1) += $(FATE_G723_1) |
|
37 |
-FATE_SAMPLES_AVCONV += $(FATE_G723_1-yes) |
|
36 |
+FATE_VOICE-$(call DEMDEC, G723_1, G723_1) += $(FATE_G723_1) |
|
38 | 37 |
fate-g723_1: $(FATE_G723_1) |
39 | 38 |
|
40 | 39 |
FATE_G726 += fate-g726-encode-2bit |
... | ... |
@@ -62,7 +61,7 @@ FATE_GSM-$(call DEMDEC, MOV, GSM) += fate-gsm-toast |
62 | 62 |
fate-gsm-toast: CMD = framecrc -i $(TARGET_SAMPLES)/gsm/sample-gsm-8000.mov -t 10 |
63 | 63 |
|
64 | 64 |
FATE_VOICE-yes += $(FATE_GSM-yes) |
65 |
-fate-gsm: $(FATE_GSM) |
|
65 |
+fate-gsm: $(FATE_GSM-yes) |
|
66 | 66 |
|
67 | 67 |
FATE_VOICE-$(call DEMDEC, QCP, QCELP) += fate-qcelp |
68 | 68 |
fate-qcelp: CMD = pcm -i $(TARGET_SAMPLES)/qcp/0036580847.QCP |