Mercurial > mplayer.hg
comparison DOCS/tech/dr-methods.txt @ 6846:f0cb56e4e986
typo fixes and updates around libavcodec
author | arpi |
---|---|
date | Tue, 30 Jul 2002 17:32:45 +0000 |
parents | e74227031a12 |
children | f665d42cd019 |
comparison
equal
deleted
inserted
replaced
6845:9acac87c7bfb | 6846:f0cb56e4e986 |
---|---|
6 | 6 |
7 At first, there are 2 different way, both called direct rendering. | 7 At first, there are 2 different way, both called direct rendering. |
8 The main point is the same, but they work different. | 8 The main point is the same, but they work different. |
9 | 9 |
10 method 1: decoding directly to externally provided buffers. | 10 method 1: decoding directly to externally provided buffers. |
11 so, the codec decodes macroblocks directly to the buffer provided by teh | 11 so, the codec decodes macroblocks directly to the buffer provided by the |
12 caller. as this buffer will be readed later (for MC of next frame) it's not | 12 caller. as this buffer will be readed later (for MC of next frame) it's not |
13 a good idea to place such buffers in slow video ram. but. | 13 a good idea to place such buffers in slow video ram. but. |
14 there are many video out drivers using buffers in system ram, and using some | 14 there are many video out drivers using buffers in system ram, and using some |
15 way of memcpy or DMA to blit it to vieo ram at display time. | 15 way of memcpy or DMA to blit it to video ram at display time. |
16 for example, Xv and X11 (normal and Shm too) are such thingie. | 16 for example, Xv and X11 (normal and Shm too) are such thingie. |
17 XImage will be a buffer in system ram (!) and X*PutImage will copy it to | 17 XImage will be a buffer in system ram (!) and X*PutImage will copy it to |
18 video ram. Only nvidia and ati rage128 Xv drivers use DMA, others just | 18 video ram. Only nvidia and ati rage128 Xv drivers use DMA, others just |
19 memcpy it. Also some opengl drivers (including Matrox) uses DMA to copy from | 19 memcpy it. Also some opengl drivers (including Matrox) uses DMA to copy from |
20 subteximage to video ram. | 20 texsubimage to video ram. |
21 The current mpalyer way mean: codec allocates some buffer, and decode image | 21 The current mplayer way mean: codec allocates some buffer, and decode image |
22 to that buffer. then this buffer is copied to X11's buffer. then Xserver | 22 to that buffer. then this buffer is copied to X11's buffer. then Xserver |
23 copies this buffer to video ram. So one more memcpy than required... | 23 copies this buffer to video ram. So one more memcpy than required... |
24 direct rendering can remove this extar memcpy, and use the Xserver's memory | 24 direct rendering can remove this extra memcpy, and use Xserver's memory |
25 buffers for decoding buffer. Note again: it helps only if the external | 25 buffers for decoding buffer. Note again: it helps only if the external |
26 buffer is in fast system ram. | 26 buffer is in fast system ram. |
27 | 27 |
28 method 2: decoding to internal buffers, but blit after each macroblocks, | 28 method 2: decoding to internal buffers, but blit after each macroblocks, |
29 including optional colorspace conversion. | 29 including optional colorspace conversion. |
45 yv12 blocks (copied 3 blocks to 3 different (Y,U,V) buffers) than doing | 45 yv12 blocks (copied 3 blocks to 3 different (Y,U,V) buffers) than doing |
46 (really unneeded) yv12->yuy2 conversion on-the-fly. | 46 (really unneeded) yv12->yuy2 conversion on-the-fly. |
47 so, divx4 codec (with -vc divx4 api) converts from its internal yv12 buffer | 47 so, divx4 codec (with -vc divx4 api) converts from its internal yv12 buffer |
48 to the external yuy2. | 48 to the external yuy2. |
49 | 49 |
50 method 2a: | |
50 libmpeg2 already uses simplified variation of this: when it finish decoding a | 51 libmpeg2 already uses simplified variation of this: when it finish decoding a |
51 slice (a horizontal line of MBs) it copies it to external (video ram) buffer | 52 slice (a horizontal line of MBs) it copies it to external (video ram) buffer |
52 (using callback to libvo), so at least it copies from L2 cache instead of | 53 (using callback to libvo), so at least it copies from L2 cache instead of |
53 slow ram. it gave me 23% -> 20% VOB decoding speedup on p3. | 54 slow ram. for non-predictive (B) frames it can re-use this cached memory |
55 for the next slice - so it uses less memory and has better cache utilization: | |
56 it gave me 23% -> 20% VOB decoding speedup on p3. libavcodec supports | |
57 per-slice callbacks too, but no slice-memory reusing for B frames yet. | |
58 | |
59 method 2b: | |
60 some codecs (indeo vfw 3/4 using IF09, and libavcodec) can export the 'bitmap' | |
61 of skipped macroblocks - so libvo driver can do selective blitting: copy only | |
62 the changed macroblocks to slow vram. | |
54 | 63 |
55 so, again: the main difference between method 1 and 2: | 64 so, again: the main difference between method 1 and 2: |
56 method1 stores decoded data only once: in the external read/write buffer. | 65 method1 stores decoded data only once: in the external read/write buffer. |
57 method2 stores decoded data twice: in its internal read/write buffer (for | 66 method2 stores decoded data twice: in its internal read/write buffer (for |
58 later reading) and in the write-only slow video ram. | 67 later reading) and in the write-only slow video ram. |
67 | 76 |
68 i hope it is clear now. | 77 i hope it is clear now. |
69 and i hope even nick understand what are we talking about... | 78 and i hope even nick understand what are we talking about... |
70 | 79 |
71 ah, and at the end, the abilities of codecs: | 80 ah, and at the end, the abilities of codecs: |
72 libmpeg2: can do method 1 and 2 (but slice level copy, not MB level) | 81 libmpeg2,libavcodec: can do method 1 and 2 (but slice level copy, not MB level) |
73 vfw, dshow: can do method 2, with static or variable address external buffer | 82 vfw, dshow: can do method 2, with static or variable address external buffer |
74 odivx, and most native codecs like fli, cvid, rle: can do method 1 | 83 odivx, and most native codecs like fli, cvid, rle: can do method 1 |
75 divx4: can do method 2 (with old odivx api it does method 1) | 84 divx4: can do method 2 (with old odivx api it does method 1) |
76 libavcodec, xanim: they currently can't do DR, but they exports their | 85 xanim: they currently can't do DR, but they exports their |
77 internal buffers. but it's very easy to implement menthod 1 support, | 86 internal buffers. but it's very easy to implement menthod 1 support, |
78 and a bit harder but possible without any rewrite to do method 2. | 87 and a bit harder but possible without any rewrite to do method 2. |
79 | 88 |
80 so, dshow and divx4 already implements all requirements of method 2. | 89 so, dshow and divx4 already implements all requirements of method 2. |
81 libmpeg2 implements method 1, and it's easy to add to libavcodec. | 90 libmpeg2 and libavcodec implements method 1 and 2a (lavc 2b too) |
82 | 91 |
83 anyway, in the ideal world, we need all codecs support both methods. | 92 anyway, in the ideal world, we need all codecs support both methods. |
84 anyway 2: in ideal world, there are no libvo drivers having buffer in system | 93 anyway 2: in ideal world, there are no libvo drivers having buffer in system |
85 ram and memcpy to video ram... | 94 ram and memcpy to video ram... |
86 anyway 3: in our really ideal world, all libvo driver has its buffers in | 95 anyway 3: in our really ideal world, all libvo driver has its buffers in |
97 3. vd asks libvo (control(VOCTRL_GET_IMAGE)), if it can provide such buffer: | 106 3. vd asks libvo (control(VOCTRL_GET_IMAGE)), if it can provide such buffer: |
98 - if it can -> do direct rendering | 107 - if it can -> do direct rendering |
99 - it it can not -> allocate system ram area with memalign()/malloc() | 108 - it it can not -> allocate system ram area with memalign()/malloc() |
100 Note: codec may request EXPORT buffer, it means buffer allocation is | 109 Note: codec may request EXPORT buffer, it means buffer allocation is |
101 done inside the codec, so we cannot do DR :( | 110 done inside the codec, so we cannot do DR :( |
102 4. codec decodes frame to the mpi struct (system ram or direct rendering) | 111 4. codec decodes one frame to the mpi struct (system ram or direct rendering) |
103 5. if it isn't DR, we call libvo's draw functions to blit image to video ram | 112 5. if it isn't DR, we call libvo's draw functions to blit image to video ram |
104 | 113 |
105 current possible buffer setups: | 114 current possible buffer setups: |
106 - EXPORT - codec handles buffer allocation and it exports its buffer pointers | 115 - EXPORT - codec handles buffer allocation and it exports its buffer pointers |
107 used for opendivx, xanim and libavcodec | 116 used for opendivx, xanim and libavcodec |
111 - TEMP - codec requires a buffer, but it doesn't depend on previous frame at all | 120 - TEMP - codec requires a buffer, but it doesn't depend on previous frame at all |
112 used for I-only codecs (like mjpeg) and for codecs supporting method-2 direct | 121 used for I-only codecs (like mjpeg) and for codecs supporting method-2 direct |
113 rendering with variable buffer address (vfw, dshow, divx4). | 122 rendering with variable buffer address (vfw, dshow, divx4). |
114 - IP - codec requires 2 (or more) read/write buffers. it's for codecs supporting | 123 - IP - codec requires 2 (or more) read/write buffers. it's for codecs supporting |
115 method-1 direct rendering but using motion compensation (ie. reading from | 124 method-1 direct rendering but using motion compensation (ie. reading from |
116 previous frame buffer). could be used for libavcodec (divx3/4,h263) later. | 125 previous frame buffer). could be used for libavcodec (divx3/4,h263). |
117 IP buffer stays from 2 (or more) STATIC buffers. | 126 IP buffer stays from 2 (or more) STATIC buffers. |
118 - IPB - similar to IP, but also have one (or more) TEMP buffers for B frames. | 127 - IPB - similar to IP, but also have one (or more) TEMP buffers for B frames. |
119 it will be used for libmpeg2 and libavcodec (mpeg1/2/4). | 128 it will be used for libmpeg2 and libavcodec (mpeg1/2/4). |
120 IPB buffer stays from 2 (or more) STATIC buffers and 1 (or more) TEMP buffer. | 129 IPB buffer stays from 2 (or more) STATIC buffers and 1 (or more) TEMP buffer. |