Skip to content

Commit cac1fb5

Browse files
committed
copy frame prop from src (regression fix #52)
1 parent ef2b378 commit cac1fb5

1 file changed

Lines changed: 9 additions & 46 deletions

File tree

src/render.c

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -899,56 +899,19 @@ AVS_VideoFrame* AVSC_CC assrender_get_frame(AVS_FilterInfo* p, int n)
899899

900900
// 1) Get upstream frame
901901
src = avs_get_frame(p->child, n);
902-
903-
// 2) Allocate a new writable destination frame
904-
dst = avs_new_video_frame_a(p->env, &p->vi, AVS_FRAME_ALIGN);
905-
if (!dst) {
906-
avs_release_video_frame(src);
902+
if (!src) {
907903
return 0;
908904
}
909905

910-
// 3) Copy src -> dst (real pixel copy), then free src
911-
912-
if (avs_is_planar(&p->vi)) {
913-
if (avs_is_rgb(&p->vi)) {
914-
// Planar RGB: R, G, B planes
915-
const int planes[3] = { AVS_PLANAR_R, AVS_PLANAR_G, AVS_PLANAR_B };
916-
for (int i = 0; i < 3; ++i) {
917-
const uint8_t* srcp = avs_get_read_ptr_p(src, planes[i]);
918-
int src_pitch = avs_get_pitch_p(src, planes[i]);
919-
uint8_t* dstp = avs_get_write_ptr_p(dst, planes[i]);
920-
int dst_pitch = avs_get_pitch_p(dst, planes[i]);
921-
int row_size = avs_get_row_size_p(src, planes[i]);
922-
int height = avs_get_height_p(src, planes[i]);
923-
avs_bit_blt(p->env, dstp, dst_pitch, srcp, src_pitch, row_size, height);
924-
}
925-
}
926-
else {
927-
// Planar YUV: Y, U, V planes
928-
const int planes[3] = { AVS_PLANAR_Y, AVS_PLANAR_U, AVS_PLANAR_V };
929-
for (int i = 0; i < 3; ++i) {
930-
const uint8_t* srcp = avs_get_read_ptr_p(src, planes[i]);
931-
int src_pitch = avs_get_pitch_p(src, planes[i]);
932-
uint8_t* dstp = avs_get_write_ptr_p(dst, planes[i]);
933-
int dst_pitch = avs_get_pitch_p(dst, planes[i]);
934-
int row_size = avs_get_row_size_p(src, planes[i]);
935-
int height = avs_get_height_p(src, planes[i]);
936-
avs_bit_blt(p->env, dstp, dst_pitch, srcp, src_pitch, row_size, height);
937-
}
938-
}
939-
}
940-
else {
941-
// Packed formats (e.g. RGB32, YUY2, etc.)
942-
const uint8_t* srcp = avs_get_read_ptr_p(src, AVS_DEFAULT_PLANE);
943-
int src_pitch = avs_get_pitch_p(src, AVS_DEFAULT_PLANE);
944-
uint8_t* dstp = avs_get_write_ptr_p(dst, AVS_DEFAULT_PLANE);
945-
int dst_pitch = avs_get_pitch_p(dst, AVS_DEFAULT_PLANE);
946-
int row_size = avs_get_row_size_p(src, AVS_DEFAULT_PLANE);
947-
int height = avs_get_height_p(src, AVS_DEFAULT_PLANE);
948-
avs_bit_blt(p->env, dstp, dst_pitch, srcp, src_pitch, row_size, height);
906+
// 2) Clone reference and make it writable (copy-on-write)
907+
dst = avs_copy_video_frame(src);
908+
if (!avs_make_writable(p->env, &dst)) {
909+
avs_release_video_frame(src);
910+
if (dst) avs_release_video_frame(dst);
911+
return 0;
949912
}
950-
951-
// Original frame no longer needed locally
913+
914+
// 3) Free src
952915
avs_release_video_frame(src);
953916

954917
// 4) Compute timestamp for libass

0 commit comments

Comments
 (0)