annotate libmpcodecs/vd_hmblck.c @ 36760:6ec928ab8112

ao_esd: remove condition that must always be true. It caused warnings about potentially uninitialized variables.
author reimar
date Sun, 16 Feb 2014 15:44:32 +0000
parents fbe4b3716aa0
children e299b6fd7eaa
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){
35149
fbe4b3716aa0 Silence a few warnings.
iive
parents: 35148
diff changeset
38 int y,x,i;
10305
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 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
42 for (i=0; i<16; i++) {
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
43 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
44 src+=16;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
45 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
46 }
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 static void de_macro_uv(unsigned char* dstu,unsigned char* dstv,unsigned char* src,int dstride,int w,int h){
35149
fbe4b3716aa0 Silence a few warnings.
iive
parents: 35148
diff changeset
51 int y,x,i;
10305
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
52 // descramble U/V plane
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
53 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
54 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
55 for (i=0; i<16; i++) {
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
56 int idx=x + (y+i)*dstride;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 src+=16;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
66 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
67 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
68 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
69 }
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 * set/get/query special features/parameters
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 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
75 return CONTROL_UNKNOWN;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
76 }
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 * init driver
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
79 */
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
80 static int init(sh_video_t *sh){
35148
89660feadcce Add necessary checks to the vd_hmblck input.
iive
parents: 35147
diff changeset
81
89660feadcce Add necessary checks to the vd_hmblck input.
iive
parents: 35147
diff changeset
82 if(sh->format != IMGFMT_HM12) return 0;
89660feadcce Add necessary checks to the vd_hmblck input.
iive
parents: 35147
diff changeset
83
89660feadcce Add necessary checks to the vd_hmblck input.
iive
parents: 35147
diff changeset
84 if((sh->disp_w&31) != 0 || (sh->disp_h&31) != 0) {
89660feadcce Add necessary checks to the vd_hmblck input.
iive
parents: 35147
diff changeset
85 mp_msg(MSGT_DECVIDEO, MSGL_ERR,
89660feadcce Add necessary checks to the vd_hmblck input.
iive
parents: 35147
diff changeset
86 "hmblck: Image size must be multiple of 32.\n");
89660feadcce Add necessary checks to the vd_hmblck input.
iive
parents: 35147
diff changeset
87 return 0;
89660feadcce Add necessary checks to the vd_hmblck input.
iive
parents: 35147
diff changeset
88 }
10305
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
89 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
90 }
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 * uninit driver
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
93 */
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
94 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
95 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
96 /*************************************************************************
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
97 * decode a frame
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
98 */
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
99 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
100 mp_image_t* mpi;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
101
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
102 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
103
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
104 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
105 sh->disp_w, sh->disp_h);
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
106 if(!mpi) return NULL;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
107
35147
4d8d26a9d66a Remove nv12/nv21 decoding from vd_hmblck.
iive
parents: 30898
diff changeset
108 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
109 de_macro_uv(mpi->planes[1],mpi->planes[2],
23622
fdd016bae333 Avoid more void * arithmetic
reimar
parents: 11766
diff changeset
110 (unsigned char *)data+mpi->w*mpi->h,mpi->stride[1],
fdd016bae333 Avoid more void * arithmetic
reimar
parents: 11766
diff changeset
111 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
112
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
113 return mpi;
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
114 }
3e40b8f879c8 HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards)
arpi
parents:
diff changeset
115 /*************************************************************************/