annotate libmpcodecs/vd_hmblck.c @ 35147:4d8d26a9d66a

Remove nv12/nv21 decoding from vd_hmblck. The codecs.conf doesn't list nv12/nv21 in the hmblck section, so the hmblck is never actually used for decoding them. Instead these pixel formats are passed through rawnv12/21 (vd_raw). They can be converted to yv12 by vf_scale. When swscale support hm12 pixel format, this decoder could be completely removed.
author iive
date Thu, 11 Oct 2012 21:50:18 +0000
parents 200a76c94ad1
children 89660feadcce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
10305
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
19 #include <stdio.h>
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
20 #include <stdlib.h>
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
21
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
22 #include "config.h"
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
23 #include "mp_msg.h"
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
24
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
25 #include "vd_internal.h"
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
26
30504
cc27da5d7286 Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents: 30421
diff changeset
27 static const vd_info_t info = {
35147
4d8d26a9d66a Remove nv12/nv21 decoding from vd_hmblck.
iive
parents: 30898
diff changeset
28 "Hauppauge Macroblock Decoder",
10305
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
29 "hmblck",
10744
666cef3fe7e3 nv21 support
alex
parents: 10305
diff changeset
30 "Alex <d18c7db@hotmail.com>, A'rpi, Alex Beregszaszi",
10305
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
31 "Alex <d18c7db@hotmail.com>",
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
32 "uncompressed"
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
33 };
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
34
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
35 LIBVD_EXTERN(hmblck)
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
36
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
37 static void de_macro_y(unsigned char* dst,unsigned char* src,int dstride,int w,int h){
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
38 unsigned int y;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
39 // descramble Y plane
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
40 for (y=0; y<h; y+=16) {
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
41 unsigned int x;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
42 for (x=0; x<w; x+=16) {
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
43 unsigned int i;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
44 for (i=0; i<16; i++) {
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
45 memcpy(dst + x + (y+i)*dstride, src, 16);
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
46 src+=16;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
47 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
48 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
49 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
50 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
51
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
52 static void de_macro_uv(unsigned char* dstu,unsigned char* dstv,unsigned char* src,int dstride,int w,int h){
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
53 unsigned int y;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
54 // descramble U/V plane
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
55 for (y=0; y<h; y+=16) {
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
56 unsigned int x;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
57 for (x=0; x<w; x+=8) {
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
58 unsigned int i;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
59 for (i=0; i<16; i++) {
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
60 int idx=x + (y+i)*dstride;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
61 dstu[idx+0]=src[0]; dstv[idx+0]=src[1];
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
62 dstu[idx+1]=src[2]; dstv[idx+1]=src[3];
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
63 dstu[idx+2]=src[4]; dstv[idx+2]=src[5];
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
64 dstu[idx+3]=src[6]; dstv[idx+3]=src[7];
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
65 dstu[idx+4]=src[8]; dstv[idx+4]=src[9];
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
66 dstu[idx+5]=src[10]; dstv[idx+5]=src[11];
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
67 dstu[idx+6]=src[12]; dstv[idx+6]=src[13];
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
68 dstu[idx+7]=src[14]; dstv[idx+7]=src[15];
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
69 src+=16;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
70 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
71 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
72 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
73 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
74
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
75 /*************************************************************************
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
76 * set/get/query special features/parameters
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
77 */
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
78 static int control(sh_video_t *sh,int cmd, void *arg,...){
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
79 return CONTROL_UNKNOWN;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
80 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
81 /*************************************************************************
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
82 * init driver
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
83 */
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
84 static int init(sh_video_t *sh){
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
85 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->format);
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
86 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
87 /*************************************************************************
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
88 * uninit driver
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
89 */
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
90 static void uninit(sh_video_t *sh){
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
91 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
92 /*************************************************************************
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
93 * decode a frame
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
94 */
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
95 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
96 mp_image_t* mpi;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
97
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
98 if(len<=0) return NULL; // skipped frame
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
99
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
100 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
101 sh->disp_w, sh->disp_h);
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
102 if(!mpi) return NULL;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
103
35147
4d8d26a9d66a Remove nv12/nv21 decoding from vd_hmblck.
iive
parents: 30898
diff changeset
104 de_macro_y(mpi->planes[0],data,mpi->stride[0],mpi->w,mpi->h);
4d8d26a9d66a Remove nv12/nv21 decoding from vd_hmblck.
iive
parents: 30898
diff changeset
105 de_macro_uv(mpi->planes[1],mpi->planes[2],
23622
fdd016bae333 Avoid more void * arithmetic
reimar
parents: 11766
diff changeset
106 (unsigned char *)data+mpi->w*mpi->h,mpi->stride[1],
fdd016bae333 Avoid more void * arithmetic
reimar
parents: 11766
diff changeset
107 mpi->w/2,mpi->h/2);
10305
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
108
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
109 return mpi;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
110 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
111 /*************************************************************************/