Skip to content

Commit

Permalink
将zoom更改为邻近填充
Browse files Browse the repository at this point in the history
  • Loading branch information
Puiching-Memory committed Feb 7, 2025
1 parent 94bb7a7 commit ecc0890
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 4 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ cython==3.1.0a1
build==1.2.2
cmake==3.31.4

# for Syntax prompt
numpy==2.2.2
scipy==1.15.1

# optional dependencies
pyinstrument==5.0.1
4 changes: 2 additions & 2 deletions running_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
out_bits=8,
out_legal=True,
)
#plt.imshow(image_martix)
#plt.show()
# plt.imshow(image_martix)
# plt.show()

break

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
include_dirs=["./libde265/build/", "./libde265/libde265/", np.get_include()],
library_dirs=["./libde265/build/libde265/Release/"],
libraries=["de265"],
extra_compile_args=["/openmp"] # only for Windows
)
extra_compile_args=["/openmp"], # only for Windows
),
]

setup(
Expand Down
24 changes: 11 additions & 13 deletions src/pylibde265/pyde265.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ from libc.stdio cimport printf
from cython.parallel import prange
import numpy as np
cimport numpy as cnp
from scipy.ndimage import zoom
# from scipy.ndimage import zoom
from pylibde265 cimport pyde265

def get_version():
return pyde265.de265_get_version().decode('ascii')

cdef class decoder(object):
cdef int threads
cdef int buffer_size
Expand Down Expand Up @@ -56,7 +56,7 @@ cdef class decoder(object):
cdef cnp.ndarray image
cdef unsigned char[:, :, ::1] image_view
cdef int i, j

while more > 0:
more = 0

Expand Down Expand Up @@ -95,20 +95,18 @@ cdef class decoder(object):
bufferCr = pyde265.de265_get_image_plane(image_ptr,2,&cstride)

image = np.empty((self.h, self.w, 3), dtype=np.uint8)
image_view = image

for i in prange(self.h, nogil=True,schedule='guided'):
for j in range(self.w):
image_view[i, j, 0] = bufferY[i * ystride + j]

# planeY = np.frombuffer(bufferY[0:self.h*self.w], dtype='uint8').reshape((self.h, self.w))
planeCb = np.frombuffer(bufferCb[0:self.hC*self.wC], dtype='uint8').reshape((self.hC, self.wC))
planeCb = zoom(planeCb,(self.w//self.wC,self.h//self.hC),order=0)
planeY = np.frombuffer(bufferY[0:self.h*self.w], dtype='uint8').reshape((self.h, self.w))
planeCb = np.frombuffer(bufferCb[0:self.hC*self.wC], dtype='uint8').reshape((self.hC, self.wC))
planeCr = np.frombuffer(bufferCr[0:self.hC*self.wC], dtype='uint8').reshape((self.hC, self.wC))
planeCr = zoom(planeCr,(self.w//self.wC,self.h//self.hC),order=0)

#planeCb = zoom(planeCb,(self.w//self.wC,self.h//self.hC),order=0)
#planeCr = zoom(planeCr,(self.w//self.wC,self.h//self.hC),order=0)

planeCb = planeCb.repeat(self.w // self.wC, axis=1).repeat(self.h // self.hC, axis=0)
planeCr = planeCr.repeat(self.w // self.wC, axis=1).repeat(self.h // self.hC, axis=0)

# image[:, :, 0] = planeY
image[:, :, 0] = planeY
image[:, :, 1] = planeCb
image[:, :, 2] = planeCr

Expand Down
Empty file removed src/pylibde265/vedio.py
Empty file.

0 comments on commit ecc0890

Please sign in to comment.