mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-03 21:23:48 +00:00
Initialize data structures correctly for the rust CEA-708 decoder #748
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @PunitLodha on GitHub (Mar 14, 2023).
Currently, the entry point for the rust decoder is here where we create a new
Dtvccstruct each time. This causes the data to be reset each timeccxr_process_cc_data()is called.Instead, we want to initialize
Dtvcconly once at the start of the program and then use it for all subsequent function calls.Steps:-
Dtvcc::new()to createDtvccusingccx_decoder_dtvcc_settingsas done here, https://github.com/CCExtractor/ccextractor/blob/master/src/lib_ccx/ccx_dtvcc.c#L76-L124ccxr_dtvcc_init()in lib.rs and use this at all places wheredtvcc_init()is being called. (Probably add a new struct field tolib_cc_decodelikedtvcc_rustand storeDtvccthere instead of using thedtvccfield)dtvcc_free()Dtvccfromdec_ctxinstead of creating a new oneAdditionally to fix mp4 code flow:-
Dtvccas done in the above steps@ArchitBhonsle commented on GitHub (Mar 15, 2023):
I was on the first task. Any idea how the
encodershould be instantiated? The current rust code just copies it over from the context it is passed while the C code does not instantiate it at all. Is it null or am I reading it wrong?@cfsmp3 commented on GitHub (Mar 15, 2023):
It should start with NULL - please send a PR to correct that in the C code :-) Just a matter of hygiene.
If you look at the actual initilization
https://github.com/CCExtractor/ccextractor/search?q=dtvcc-%3Eencoder
There a couple of places in which it happens. But it should start with NULL when the context is created.
@PunitLodha commented on GitHub (Mar 15, 2023):
As @cfsmp3 mentioned, it should be initialized to NULL. You should also add a function to set the value for
encoderfield, which is called whenever the value fordtvcc->encoderis updated in the C code.On a side note, If you are working on this issue, I recommend you to open a draft PR and keep pushing your changes there, so that I can review each step individually. This issue is quite a bit of work, and reviewing a huge PR would be difficult
@ArchitBhonsle commented on GitHub (Mar 16, 2023):
If could push my progress but because of how I'm working, the commits themselves would fail to build. Is that okay?
@ArchitBhonsle commented on GitHub (Mar 16, 2023):
Also how do I approach the compatibility issue. The
encoderfor example. It would be initialized toNULLbut in Rust should I use the Rusty approach of usingOptionand write getters and setters to work with it in C or usestd::ptr::null()? I would prefer the former but it might necessitate more changes on the C side.@ArchitBhonsle commented on GitHub (Mar 16, 2023):
And other issue is stuff like
dtvcc_tv_screenwhere in C we just allocate memory for it and assign some of the values while the rest are left as garbage. While instantiating these structs in Rust I have to assign all the values, right? Which is fine for simple values but when there's nested structs (likewindowsindtvcc_tv_screen) it can get cumbersome.Edit: For now I have added
dervive_default(true)to the bindgen builder which makes this a lot simpler. But do tell me if you guys have any better ideas.Edit 2: This conflicts with the manually defined
Defaultimplementations fordtvcc_pen_attribsanddtvcc_pen_color. I'll rename these tonewfor now.@ArchitBhonsle commented on GitHub (Mar 16, 2023):
@PunitLodha here's the PR #1501. For now I've just rewritten
Dtvcc::new().@ArchitBhonsle commented on GitHub (Mar 18, 2023):
Hey @cfsmp3. Of the 3 code results in the link you have sent only the first two,
general_loop.candmp4.care initializations that should affect the Rust decoder right?@cfsmp3 commented on GitHub (Mar 18, 2023):
I haven't tracked it down, but in general any structure should have all its fields initialized with something when it's created :-)
@ArchitBhonsle commented on GitHub (Apr 11, 2023):
@PunitLodha for the mp4 part, do I just expose another extern function from Rust to call this or somehow reuse this?
@PunitLodha commented on GitHub (Apr 12, 2023):
You'll need to expose another extern function
@asher-gh commented on GitHub (Jan 16, 2024):
Seems like #1501 is not active anymore. What's the best way to get
ccx_decoder_dtvcc_settingswhen callingDtvcc::newinccxr_process_cc_datahere?@IshanGrover2004 commented on GitHub (Feb 20, 2024):
I have started working on this issue & I have raised a Draft PR #1599 as it is WIP.
Till now I have done the first task which is
Changing Dtvcc::new() to create Dtvcc using ccx_decoder_dtvcc_settingsFeedbacks are appreciated