Skip to content

Commit 6a5e8a0

Browse files
committed
encrypt all syntax elements
1 parent 9f99eab commit 6a5e8a0

File tree

5 files changed

+285
-22
lines changed

5 files changed

+285
-22
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ else()
353353
endif()
354354
add_library (LibOpenHevcWrapper ${libfilenames} ${YASM_OBJECTS})
355355

356-
target_link_libraries(LibOpenHevcWrapper m)
356+
target_link_libraries(LibOpenHevcWrapper cryptopp)
357357

358358
include_directories(. gpac/modules/openhevc_dec/ platform/x86/)
359359

libavcodec/crypto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ void DecryptC(Crypto_Handle hdl, const unsigned char *in_stream, int size_bits,
116116
}
117117

118118
void DeleteCryptoC(Crypto_Handle hdl) {
119-
DeleteCryptoC(hdl);
119+
DeleteCrypto((AESDecoder *)hdl);
120120
}

libavcodec/hevc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,7 +4072,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
40724072
int i;
40734073

40744074
pic_arrays_free(s);
4075-
4075+
DeleteCryptoC(s->HEVClc->dbs_g);
40764076
av_freep(&s->md5_ctx);
40774077

40784078
for(i=0; i < s->nals_allocated; i++) {
@@ -4148,7 +4148,7 @@ static av_cold int hevc_init_context(AVCodecContext *avctx)
41484148
s->dynamic_alloc += HEVC_CONTEXTS;
41494149
if (!s->cabac_state)
41504150
goto fail;
4151-
4151+
s->HEVClc->dbs_g = InitC();
41524152
s->tmp_frame = av_frame_alloc();
41534153
s->dynamic_alloc += sizeof(AVFrame);
41544154
if (!s->tmp_frame)
@@ -4367,6 +4367,8 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
43674367
return ret;
43684368

43694369
s->picture_struct = 0;
4370+
s->prev_pos = 0;
4371+
s->encrypt_params = HEVC_CRYPTO_MV_SIGNS | HEVC_CRYPTO_MVs | HEVC_CRYPTO_TRANSF_COEFF_SIGNS | HEVC_CRYPTO_TRANSF_COEFFS;
43704372

43714373
if (avctx->extradata_size > 0 && avctx->extradata) {
43724374
ret = hevc_decode_extradata(s);

libavcodec/hevc.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
#include "thread.h"
3737
#include "videodsp.h"
3838
#include "hevc_defs.h"
39+
#include "crypto.h"
40+
41+
#define EncryptMVDiffSign 1
42+
3943

4044
#define PARALLEL_SLICE 0
4145
#define PARALLEL_FILTERS 0
@@ -436,6 +440,18 @@ enum ChromaFormat
436440
#endif
437441
};
438442

443+
/*
444+
Encryption configuration
445+
*/
446+
enum hevc_crypto_features {
447+
HEVC_CRYPTO_OFF = 0,
448+
HEVC_CRYPTO_MVs = (1 << 0),
449+
HEVC_CRYPTO_MV_SIGNS = (1 << 1),
450+
HEVC_CRYPTO_TRANSF_COEFFS = (1 << 2),
451+
HEVC_CRYPTO_TRANSF_COEFF_SIGNS = (1 << 3),
452+
HEVC_CRYPTO_ON = (1 << 4) - 1,
453+
};
454+
439455
#if REPN_FORMAT_IN_VPS
440456
typedef struct RepFormat
441457
{
@@ -1095,6 +1111,7 @@ typedef struct HEVCLocalContext {
10951111
uint8_t slice_or_tiles_up_boundary;
10961112

10971113
int ctb_tile_rs;
1114+
Crypto_Handle dbs_g;
10981115

10991116
} HEVCLocalContext;
11001117

@@ -1263,6 +1280,8 @@ typedef struct HEVCContext {
12631280

12641281
uint8_t force_first_slice_in_pic;
12651282
int64_t last_frame_pts;
1283+
uint8_t encrypt_params;
1284+
uint32_t prev_pos;
12661285
} HEVCContext;
12671286

12681287
int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps,

0 commit comments

Comments
 (0)