@@ -856,7 +856,7 @@ napi_value setCodecCtxTimeBase(napi_env env, napi_callback_info info) {
856856 napi_status status;
857857 napi_value result, element;
858858 napi_valuetype type;
859- bool isArray;
859+ // bool isArray;
860860 AVCodecContext* codec;
861861
862862 size_t argc = 1 ;
@@ -866,14 +866,16 @@ napi_value setCodecCtxTimeBase(napi_env env, napi_callback_info info) {
866866 if (argc < 1 ) {
867867 NAPI_THROW_ERROR (" A value is required to set the time_base property." );
868868 }
869- status = napi_is_array (env, args[0 ], &isArray);
870- CHECK_STATUS;
871- if (!isArray) {
872- NAPI_THROW_ERROR (" An array of two numbers is required to set the time_base property." );
873- }
869+ // status = napi_is_array(env, args[0], &isArray);
870+ // CHECK_STATUS;
871+ // if (!isArray) {
872+ // NAPI_THROW_ERROR("An array of two numbers is required to set the time_base property.");
873+ // }
874874 for ( int x = 0 ; x < 2 ; x++ ) {
875875 status = napi_get_element (env, args[0 ], x, &element);
876- CHECK_STATUS;
876+ if (status != napi_ok) {
877+ NAPI_THROW_ERROR (" An array of two numbers is required to set the time_base property." );
878+ }
877879 status = napi_typeof (env, element, &type);
878880 CHECK_STATUS;
879881 if (type != napi_number) {
@@ -1738,13 +1740,20 @@ napi_value setCodecCtxSliceOffset(napi_env env, napi_callback_info info) {
17381740 status = napi_is_array (env, args[0 ], &isArray);
17391741 CHECK_STATUS;
17401742 if (!isArray) {
1741- NAPI_THROW_ERROR (" An array of numbers is required to set the slice_offset property." );
1743+ napi_value propNames;
1744+ status = napi_get_property_names (env, args[0 ], &propNames);
1745+ CHECK_STATUS;
1746+ status = napi_get_array_length (env, propNames, (uint32_t *) &sliceCount);
1747+ CHECK_STATUS;
1748+ } else {
1749+ status = napi_get_array_length (env, args[0 ], (uint32_t *) &sliceCount);
1750+ CHECK_STATUS;
17421751 }
1743- status = napi_get_array_length (env, args[0 ], (uint32_t *) &sliceCount);
1744- CHECK_STATUS;
17451752 for ( int x = 0 ; x < sliceCount ; x++ ) {
17461753 status = napi_get_element (env, args[0 ], x, &element);
1747- CHECK_STATUS;
1754+ if (status != napi_ok) {
1755+ NAPI_THROW_ERROR (" An array of numbers is required to set the slice_offset property." );
1756+ }
17481757 status = napi_typeof (env, element, &type);
17491758 CHECK_STATUS;
17501759 if (type != napi_number) {
@@ -1793,7 +1802,7 @@ napi_value setCodecCtxSampleAspRt(napi_env env, napi_callback_info info) {
17931802 napi_status status;
17941803 napi_value result, element;
17951804 napi_valuetype type;
1796- bool isArray;
1805+ // bool isArray;
17971806 AVCodecContext* codec;
17981807
17991808 size_t argc = 1 ;
@@ -1803,14 +1812,16 @@ napi_value setCodecCtxSampleAspRt(napi_env env, napi_callback_info info) {
18031812 if (argc < 1 ) {
18041813 NAPI_THROW_ERROR (" A value is required to set the sample_aspect_ratio property." );
18051814 }
1806- status = napi_is_array (env, args[0 ], &isArray);
1807- CHECK_STATUS;
1808- if (!isArray) {
1809- NAPI_THROW_ERROR (" An array of two numbers is required to set the sample_aspect_ratio property." );
1810- }
1815+ // status = napi_is_array(env, args[0], &isArray);
1816+ // CHECK_STATUS;
1817+ // if (!isArray) {
1818+ // NAPI_THROW_ERROR("An array of two numbers is required to set the sample_aspect_ratio property.");
1819+ // }
18111820 for ( int x = 0 ; x < 2 ; x++ ) {
18121821 status = napi_get_element (env, args[0 ], x, &element);
1813- CHECK_STATUS;
1822+ if (status != napi_ok) {
1823+ NAPI_THROW_ERROR (" An array of two numbers is required to set the sample_aspect_ratio property." );
1824+ }
18141825 status = napi_typeof (env, element, &type);
18151826 CHECK_STATUS;
18161827 if (type != napi_number) {
@@ -2462,7 +2473,7 @@ napi_value setCodecCtxIntraMatrix(napi_env env, napi_callback_info info) {
24622473 napi_status status;
24632474 napi_value result, element;
24642475 napi_valuetype type;
2465- bool isArray;
2476+ // bool isArray;
24662477 AVCodecContext* codec;
24672478 uint32_t uThirtwo;
24682479
@@ -2479,15 +2490,17 @@ napi_value setCodecCtxIntraMatrix(napi_env env, napi_callback_info info) {
24792490 codec->intra_matrix = nullptr ;
24802491 goto done;
24812492 }
2482- status = napi_is_array (env, args[0 ], &isArray);
2483- CHECK_STATUS;
2484- if (!isArray) {
2485- NAPI_THROW_ERROR (" An array of numbers is required to set the intra_matrix property." );
2486- }
2493+ // status = napi_is_array(env, args[0], &isArray);
2494+ // CHECK_STATUS;
2495+ // if (!isArray) {
2496+ // NAPI_THROW_ERROR("An array of numbers is required to set the intra_matrix property.");
2497+ // }
24872498 codec->intra_matrix = (uint16_t *) av_mallocz (sizeof (uint16_t ) * 64 );
24882499 for ( int x = 0 ; x < 64 ; x++ ) {
24892500 status = napi_get_element (env, args[0 ], x, &element);
2490- CHECK_STATUS;
2501+ if (status != napi_ok) {
2502+ NAPI_THROW_ERROR (" An array of numbers is required to set the intra_matrix property." );
2503+ }
24912504 status = napi_typeof (env, element, &type);
24922505 CHECK_STATUS;
24932506 if (type == napi_number) {
@@ -2534,7 +2547,7 @@ napi_value setCodecCtxInterMatrix(napi_env env, napi_callback_info info) {
25342547 napi_status status;
25352548 napi_value result, element;
25362549 napi_valuetype type;
2537- bool isArray;
2550+ // bool isArray;
25382551 AVCodecContext* codec;
25392552 uint32_t uThirtwo;
25402553
@@ -2551,15 +2564,17 @@ napi_value setCodecCtxInterMatrix(napi_env env, napi_callback_info info) {
25512564 codec->intra_matrix = nullptr ;
25522565 goto done;
25532566 }
2554- status = napi_is_array (env, args[0 ], &isArray);
2555- CHECK_STATUS;
2556- if (!isArray) {
2557- NAPI_THROW_ERROR (" An array of numbers is required to set the inter_matrix property." );
2558- }
2567+ // status = napi_is_array(env, args[0], &isArray);
2568+ // CHECK_STATUS;
2569+ // if (!isArray) {
2570+ // NAPI_THROW_ERROR("An array of numbers is required to set the inter_matrix property.");
2571+ // }
25592572 codec->inter_matrix = (uint16_t *) av_mallocz (sizeof (uint16_t ) * 64 );
25602573 for ( int x = 0 ; x < 64 ; x++ ) {
25612574 status = napi_get_element (env, args[0 ], x, &element);
2562- CHECK_STATUS;
2575+ if (status != napi_ok) {
2576+ NAPI_THROW_ERROR (" An array of 64 numbers is required to set the inter_matrix property." );
2577+ }
25632578 status = napi_typeof (env, element, &type);
25642579 CHECK_STATUS;
25652580 if (type == napi_number) {
@@ -4178,10 +4193,19 @@ napi_value setCodecCtxRcOverride(napi_env env, napi_callback_info info) {
41784193 status = napi_is_array (env, args[0 ], &isArray);
41794194 CHECK_STATUS;
41804195 if (!isArray) {
4181- NAPI_THROW_ERROR (" An array of RcOverride values is required to set the rc_override property." );
4182- }
4183- status = napi_get_array_length (env, args[0 ], &count);
4184- CHECK_STATUS;
4196+ napi_value propNames;
4197+ status = napi_get_property_names (env, args[0 ], &propNames);
4198+ CHECK_STATUS;
4199+ status = napi_get_array_length (env, propNames, &count);
4200+ CHECK_STATUS;
4201+ status = napi_get_element (env, args[0 ], 0 , &element);
4202+ if (status != napi_ok) {
4203+ NAPI_THROW_ERROR (" An array of RcOverride values is required to set the rc_override property." );
4204+ }
4205+ } else {
4206+ status = napi_get_array_length (env, args[0 ], &count);
4207+ CHECK_STATUS;
4208+ }
41854209 if (count == 0 ) {
41864210 if (codec->rc_override != nullptr ) {
41874211 av_freep (&codec->rc_override );
@@ -5934,7 +5958,7 @@ napi_value setCodecCtxFramerate(napi_env env, napi_callback_info info) {
59345958 napi_status status;
59355959 napi_value result, element;
59365960 napi_valuetype type;
5937- bool isArray;
5961+ // bool isArray;
59385962 AVCodecContext* codec;
59395963
59405964 size_t argc = 1 ;
@@ -5944,14 +5968,16 @@ napi_value setCodecCtxFramerate(napi_env env, napi_callback_info info) {
59445968 if (argc < 1 ) {
59455969 NAPI_THROW_ERROR (" A value is required to set the framerate property." );
59465970 }
5947- status = napi_is_array (env, args[0 ], &isArray);
5948- CHECK_STATUS;
5949- if (!isArray) {
5950- NAPI_THROW_ERROR (" An array of two numbers is required to set the framerate property." );
5951- }
5971+ // status = napi_is_array(env, args[0], &isArray);
5972+ // CHECK_STATUS;
5973+ // if (!isArray) {
5974+ // NAPI_THROW_ERROR("An array of two numbers is required to set the framerate property.");
5975+ // }
59525976 for ( int x = 0 ; x < 2 ; x++ ) {
59535977 status = napi_get_element (env, args[0 ], x, &element);
5954- CHECK_STATUS;
5978+ if (status != napi_ok) {
5979+ NAPI_THROW_ERROR (" An array of two numbers is required to set the framerate property." );
5980+ }
59555981 status = napi_typeof (env, element, &type);
59565982 CHECK_STATUS;
59575983 if (type != napi_number) {
@@ -6021,7 +6047,7 @@ napi_value setCodecCtxPktTimebase(napi_env env, napi_callback_info info) {
60216047 napi_status status;
60226048 napi_value result, element;
60236049 napi_valuetype type;
6024- bool isArray;
6050+ // bool isArray;
60256051 AVCodecContext* codec;
60266052
60276053 size_t argc = 1 ;
@@ -6031,14 +6057,16 @@ napi_value setCodecCtxPktTimebase(napi_env env, napi_callback_info info) {
60316057 if (argc < 1 ) {
60326058 NAPI_THROW_ERROR (" A value is required to set the pkt_timebase property." );
60336059 }
6034- status = napi_is_array (env, args[0 ], &isArray);
6035- CHECK_STATUS;
6036- if (!isArray) {
6037- NAPI_THROW_ERROR (" An array of two numbers is required to set the pkt_timebase property." );
6038- }
6060+ // status = napi_is_array(env, args[0], &isArray);
6061+ // CHECK_STATUS;
6062+ // if (!isArray) {
6063+ // NAPI_THROW_ERROR("An array of two numbers is required to set the pkt_timebase property.");
6064+ // }
60396065 for ( int x = 0 ; x < 2 ; x++ ) {
60406066 status = napi_get_element (env, args[0 ], x, &element);
6041- CHECK_STATUS;
6067+ if (status != napi_ok) {
6068+ NAPI_THROW_ERROR (" An array of two numbers is required to set the pkt_timebase property." );
6069+ }
60426070 status = napi_typeof (env, element, &type);
60436071 CHECK_STATUS;
60446072 if (type != napi_number) {
@@ -6243,7 +6271,7 @@ napi_value setCodecCtxChromaIntraMatrix(napi_env env, napi_callback_info info) {
62436271 napi_status status;
62446272 napi_value result, element;
62456273 napi_valuetype type;
6246- bool isArray;
6274+ // bool isArray;
62476275 AVCodecContext* codec;
62486276 uint32_t uThirtwo;
62496277
@@ -6260,15 +6288,17 @@ napi_value setCodecCtxChromaIntraMatrix(napi_env env, napi_callback_info info) {
62606288 codec->chroma_intra_matrix = nullptr ;
62616289 goto done;
62626290 }
6263- status = napi_is_array (env, args[0 ], &isArray);
6264- CHECK_STATUS;
6265- if (!isArray) {
6266- NAPI_THROW_ERROR (" An array of numbers is required to set the chroma_intra_matrix property." );
6267- }
6291+ // status = napi_is_array(env, args[0], &isArray);
6292+ // CHECK_STATUS;
6293+ // if (!isArray) {
6294+ // NAPI_THROW_ERROR("An array of 64 numbers is required to set the chroma_intra_matrix property.");
6295+ // }
62686296 codec->chroma_intra_matrix = (uint16_t *) av_mallocz (sizeof (uint16_t ) * 64 );
62696297 for ( int x = 0 ; x < 64 ; x++ ) {
62706298 status = napi_get_element (env, args[0 ], x, &element);
6271- CHECK_STATUS;
6299+ if (status != napi_ok) {
6300+ NAPI_THROW_ERROR (" An array of 64 numbers is required to set the chroma_intra_matrix property." );
6301+ }
62726302 status = napi_typeof (env, element, &type);
62736303 CHECK_STATUS;
62746304 if (type == napi_number) {
0 commit comments